{"id":43099693,"url":"https://github.com/colorjs/pick-a-good-color","last_synced_at":"2026-01-31T17:09:50.413Z","repository":{"id":57323809,"uuid":"98152631","full_name":"colorjs/pick-a-good-color","owner":"colorjs","description":"Choose the boldest and most accessible color for a given background.","archived":false,"fork":false,"pushed_at":"2018-04-14T04:24:36.000Z","size":15,"stargazers_count":19,"open_issues_count":0,"forks_count":3,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-11-17T00:20:25.063Z","etag":null,"topics":["accessibility","color","contrast","magic"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/colorjs.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-24T05:36:37.000Z","updated_at":"2023-01-24T01:17:36.000Z","dependencies_parsed_at":"2022-09-09T08:10:53.292Z","dependency_job_id":null,"html_url":"https://github.com/colorjs/pick-a-good-color","commit_stats":null,"previous_names":["zeke/pick-a-good-color"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/colorjs/pick-a-good-color","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colorjs%2Fpick-a-good-color","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colorjs%2Fpick-a-good-color/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colorjs%2Fpick-a-good-color/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colorjs%2Fpick-a-good-color/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/colorjs","download_url":"https://codeload.github.com/colorjs/pick-a-good-color/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colorjs%2Fpick-a-good-color/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28948358,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T14:26:55.697Z","status":"ssl_error","status_checked_at":"2026-01-31T14:26:52.545Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["accessibility","color","contrast","magic"],"created_at":"2026-01-31T17:09:45.364Z","updated_at":"2026-01-31T17:09:50.402Z","avatar_url":"https://github.com/colorjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pick-a-good-color \n\n\u003e Choose the boldest and most accessible color for a given background.\n\n[![electron app icon colors](https://user-images.githubusercontent.com/2289/29397734-370d9d00-82d5-11e7-8689-d32e40256d67.png)](https://user-images.githubusercontent.com/2289/29397854-e127ed86-82d5-11e7-9837-e3016c03ce8e.png)\n\n## Installation\n\n```sh\nnpm install pick-a-good-color --save\n```\n\n## Usage\n\nGiven an array of colors, this function will attempt to find the most saturated \ncolor that meets the \n[recommended WCAG contrast ratio](https://www.w3.org/TR/WCAG/#visual-audio-contrast)\nof 4.5:1. If none of the given colors meet the criteria, then the most saturated \ncolor  in the array will be adjusted to meet the contrast requirements using the \n[make-color-accessible](http://ghub.io/make-color-accessible) module.\n\nBy default, this module will pick a color that will work on a white background:\n\n```js\nconst pick = require('pick-a-good-color')\nconst colors = ['#DB1AC2', '#C70C4D', '#6B0964', '#5D2BD6', '#088C00']\nconst goodColor = pick(colors)\n// =\u003e #C70C4D\n```\n\nIf you need a color that will work on a black background, set the \n`background` option:\n\n```js\nconst goodColor = pick(colors, {background: 'black'})\n```\n\nFor large text, the WCAG \n[recommends](https://www.w3.org/TR/WCAG/#visual-audio-contrast)\na lower minimum ratio of 3:1.\nTo change the minimum required contrast, set the `contrast` option:\n\n```js\nconst goodColor = pick(colors, {contrast: 3})\n```\n\n## API\n\n### `pickAGoodColor(colors[, options])`\n\n- `colors` - An array of hex strings, html color names like `black` or `white`, or any other input accepted by the [color2](https://github.com/scrapjs/color#api) module. (required)\n- `options` - An object. Optional.\n  - `contrast` - A number representing the minimum required contrast ratio between `options.background` and a color in the `colors` argument. Defaults to the [WCAG recommendation](https://www.w3.org/TR/WCAG20-TECHS/G18.html) of `4.5`. Can be any number between 1 and 21.\n  - `background` - A hex string, html color name like `black` or `white`, or any other input accepted by the [color2](https://github.com/scrapjs/color#api) module. Defaults to `white`.\n\n## Tests\n\n```sh\nnpm install\nnpm test\n```\n\n## See Also\n\n- [leaverou.github.io/contrast-ratio](http://leaverou.github.io/contrast-ratio/) - A tool to calculate the contrast ratio between any two valid CSS colors. \n\n## Dependencies\n\n- [color2](https://github.com/dfcreative/color): Stateful implementation of color\n- [lodash](https://github.com/lodash/lodash): Lodash modular utilities.\n- [make-color-accessible](https://github.com/colorjs/make-color-accessible): produce colors that meet web content accessibility guidelines\n\n## Dev Dependencies\n\n- [budo](https://github.com/mattdesl/budo): a browserify server for rapid prototyping\n- [chai](https://github.com/chaijs/chai): BDD/TDD assertion library for node.js and the browser. Test framework agnostic.\n- [electron-apps](https://github.com/electron/electron-apps): A collection of apps built on Electron\n- [mocha](https://github.com/mochajs/mocha): simple, flexible, fun test framework\n- [standard](https://github.com/feross/standard): JavaScript Standard Style\n- [standard-markdown](https://github.com/colorjs/standard-markdown): Test your Markdown files for Standard JavaScript Style™\n- [yo-yo](https://github.com/maxogden/yo-yo): A tiny library for building modular UI components using DOM diffing and ES6 tagged template literals\n\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolorjs%2Fpick-a-good-color","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcolorjs%2Fpick-a-good-color","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolorjs%2Fpick-a-good-color/lists"}