
Security News
CISA Kills Off RSS Feeds for KEVs and Cyber Alerts
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
get-contrast
Advanced tools
Get the contrast ratio and WCAG score between common CSS color types.
Get the contrast ratio and WCAG score for two colors based on W3C Accessibility Standards. It handles rgb, rgba, hex, hsl, hsla, and named CSS colors.
npm i --save get-contrast
# yarn add get-contrast
const contrast = require("get-contrast");
contrast.ratio("#fafafa", "rgba(0,0,0,.75)"); // => 10
contrast.score("#fafafa", "rgba(0,0,0,.75)"); // => 'AAA'
contrast.isAccessible("#fafafa", "rgba(0,0,0,.75)"); // => true
contrast.isAccessible("#fafafa", "#fff"); // => false
contrast.score("rebeccapurple", "tomato"); // => 'F'
ignoreAlpha
(default: false
) - Don't raise an error when transparent values are passed (rgba(0, 0, 0, 0)
)contrast.score("rgba(0, 0, 0, 0)", "rgba(255, 255, 255, 0)", {
ignoreAlpha: true,
}); // => 'AAA'
This module includes a command line interface contrast
.
$ npm i get-contrast -g
$ contrast "#000" "#fff"
Ratio: 21
Score: AAA
# The second parameter defaults to #fff
$ contrast white
Ratio: 1
Score: F
The contrast is not accessible.
# Contrast will exit with an error code, when the values are not accessible.
$ contrast "#ff0" "#fff" && ./deploy.sh
Ratio: 1.0738392309265699
Score: F
The contrast is not accessible.
Uses the following packages:
Inspired by:
MIT
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)Authored by John Otander (@4lpine).
FAQs
Get the contrast ratio and WCAG score between common CSS color types.
The npm package get-contrast receives a total of 3,902 weekly downloads. As such, get-contrast popularity was classified as popular.
We found that get-contrast demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.