{"id":15502861,"url":"https://github.com/johno/get-contrast","last_synced_at":"2025-04-09T19:18:58.873Z","repository":{"id":24451971,"uuid":"27854569","full_name":"johno/get-contrast","owner":"johno","description":"Get the contrast ratio and WCAG score between two colors in order to ensure accessibility","archived":false,"fork":false,"pushed_at":"2023-10-29T13:24:20.000Z","size":293,"stargazers_count":84,"open_issues_count":7,"forks_count":9,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-09T19:18:55.098Z","etag":null,"topics":["a11y","accessibility","color","wcag-contrast"],"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/johno.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-12-11T04:47:49.000Z","updated_at":"2025-03-07T16:25:10.000Z","dependencies_parsed_at":"2024-06-18T15:16:31.069Z","dependency_job_id":"ca9073d8-1183-4f64-84fe-d9d0a75a8d39","html_url":"https://github.com/johno/get-contrast","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johno%2Fget-contrast","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johno%2Fget-contrast/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johno%2Fget-contrast/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johno%2Fget-contrast/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johno","download_url":"https://codeload.github.com/johno/get-contrast/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248094990,"owners_count":21046770,"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":["a11y","accessibility","color","wcag-contrast"],"created_at":"2024-10-02T09:11:22.657Z","updated_at":"2025-04-09T19:18:58.850Z","avatar_url":"https://github.com/johno.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# get-contrast\n\nGet the contrast ratio and WCAG score for two colors based on\n[W3C Accessibility Standards](http://www.w3.org/TR/WCAG20/#visual-audio-contrast-contrast).\nIt handles rgb, rgba, hex, hsl, hsla, and named CSS colors.\n\n## Installation\n\n```\nnpm i --save get-contrast\n# yarn add get-contrast\n```\n\n## Usage\n\n```javascript\nconst contrast = require(\"get-contrast\");\n\ncontrast.ratio(\"#fafafa\", \"rgba(0,0,0,.75)\"); // =\u003e 10\ncontrast.score(\"#fafafa\", \"rgba(0,0,0,.75)\"); // =\u003e 'AAA'\ncontrast.isAccessible(\"#fafafa\", \"rgba(0,0,0,.75)\"); // =\u003e true\ncontrast.isAccessible(\"#fafafa\", \"#fff\"); // =\u003e false\ncontrast.score(\"rebeccapurple\", \"tomato\"); // =\u003e 'F'\n```\n\n#### Options\n\n- `ignoreAlpha` (default: `false`) - Don't raise an error when transparent values are passed (`rgba(0, 0, 0, 0)`)\n\n```js\ncontrast.score(\"rgba(0, 0, 0, 0)\", \"rgba(255, 255, 255, 0)\", {\n  ignoreAlpha: true,\n}); // =\u003e 'AAA'\n```\n\n## CLI\n\nThis module includes a command line interface `contrast`.\n\n```sh\n$ npm i get-contrast -g\n$ contrast \"#000\" \"#fff\"\nRatio: 21\nScore: AAA\n# The second parameter defaults to #fff\n$ contrast white\nRatio: 1\nScore: F\nThe contrast is not accessible.\n# Contrast will exit with an error code, when the values are not accessible.\n$ contrast \"#ff0\" \"#fff\" \u0026\u0026 ./deploy.sh\nRatio: 1.0738392309265699\nScore: F\nThe contrast is not accessible.\n```\n\n## Related\n\nUses the following packages:\n\n- \u003chttps://github.com/tmcw/wcag-contrast\u003e\n- \u003chttps://github.com/kamicane/rgb\u003e\n\nInspired by:\n\n- \u003chttps://leaverou.github.com/contrast-ratio\u003e\n\n## License\n\nMIT\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\n\u003e Authored by [John Otander](http://johno.com) ([@4lpine](https://twitter.com/4lpine)).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohno%2Fget-contrast","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohno%2Fget-contrast","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohno%2Fget-contrast/lists"}