{"id":17242588,"url":"https://github.com/robinweser/small-color","last_synced_at":"2025-04-14T03:25:20.582Z","repository":{"id":36272430,"uuid":"222621453","full_name":"robinweser/small-color","owner":"robinweser","description":"Tiny (0.8kb), opinionated \u0026 tree-shakable alternative to color ","archived":false,"fork":false,"pushed_at":"2022-12-10T09:26:20.000Z","size":249,"stargazers_count":7,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T12:41:09.525Z","etag":null,"topics":["color","color-manipulation","css-color","hsl-to-rgb","parser","rgb-to-hsl"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robinweser.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":"github:[robinweser]"},"created_at":"2019-11-19T06:09:47.000Z","updated_at":"2022-04-19T20:26:57.000Z","dependencies_parsed_at":"2023-01-17T00:01:05.396Z","dependency_job_id":null,"html_url":"https://github.com/robinweser/small-color","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robinweser%2Fsmall-color","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robinweser%2Fsmall-color/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robinweser%2Fsmall-color/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robinweser%2Fsmall-color/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robinweser","download_url":"https://codeload.github.com/robinweser/small-color/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248814604,"owners_count":21165791,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["color","color-manipulation","css-color","hsl-to-rgb","parser","rgb-to-hsl"],"created_at":"2024-10-15T06:13:35.485Z","updated_at":"2025-04-14T03:25:20.563Z","avatar_url":"https://github.com/robinweser.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# small-color\n\nA tiny (0.8kb), limited \u0026 tree-shakable alternative to [color](https://github.com/Qix-/color).\u003cbr\u003e\nIt is very limited and optimized for runtime usage in the browser.\u003cbr\u003e\nIt only supports a subset of color and does **not** have input validation.\n\nIt has zero dependencies and supports tree-shaking making its size even smaller depending on the functions used.\n\n## Installation\n\n```sh\nyarn add small-color\n```\n\n## Limitations\n\n1. It only supports valid CSS color string to be passed in\n2. It currently only supports rgb(a) and hsl(a) color values\n3. It does not optimize output values (e.g. round decimals to X digits)\n4. It does not validate input values\n5. It always returns `hsla` or `rgba` (even if alpha=1)\n\n## Usage\n\nIn order to use any manipulation function, we need to parse our color string.\u003cbr /\u003e\nNow we can manipulate it until we finally generate a string again.\n\n```javascript\nimport { parse, toRgb, desaturate, lighten, fade } from 'small-color'\n\nconst color = parse('rgb(255, 0, 100)')\n\nconst lightened = lighten(color, 0.5)\nconst saturated = desaturate(lightened, 0.3)\nconst faded = fade(saturated, 0.5)\n\nconst output = toRgb(faded)\n\nconsole.log(output) // =\u003e rgba(236,147,182,0.5)\n```\n\n## API\n\n- parse(string): color\n- lighten(color, float): color\n- darken(color, float): color\n- saturate(color, float): color\n- desaturate(color, float): color\n- fade(color, float): color\n- opaquer(color, float): color\n- grayscale(color): color\n- toRgb(color): string\n- toHsl(color): string\n\n## License\n\nsmall-color is licensed under the [MIT License](http://opensource.org/licenses/MIT).\u003cbr\u003e\nDocumentation is licensed under [Creative Common License](http://creativecommons.org/licenses/by/4.0/).\u003cbr\u003e\nCreated with ♥ by [@robinweser](http://weser.io) and all the great contributors.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobinweser%2Fsmall-color","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobinweser%2Fsmall-color","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobinweser%2Fsmall-color/lists"}