wcag color contrast

CircleCI

This module produces WCAG(link is external) contrast ratio(link is external)
measurement and scoring. It's an accessibility standard, intended to make sure websites have high enough contrast to be readable by everyone, including people with low vision(link is external) and age-related vision problems. This module is a low-level utility, useful for its implementation of the underlying math: to test a page, you'll want to use something like Google Chrome’s Lighthouse tools(link is external), or the axe extension(link is external) for Chrome and Firefox.

I (personally, speaking as Tom) have doubts about the universality, accuracy, and application of this particular standard(link is external). High contrast is a good value, but I argue that the standard is over-strict and doesn't precisely match human perception.

API

luminance

Get the contrast ratio between two relative luminance values

Parameters

Examples

luminance(1, 1); // = 1

Returns number(link is external) contrast ratio

rgb

Get a score for the contrast between two colors as rgb triplets

Parameters

Examples

rgb([0, 0, 0], [255, 255, 255]); // = 21

Returns number(link is external) contrast ratio

hex

Get a score for the contrast between two colors as hex strings

Parameters

Examples

hex('#000', '#fff'); // = 21

Returns number(link is external) contrast ratio

score

Get a textual score from a numeric contrast value

Parameters

Examples

score(10); // = 'AAA'

Returns string(link is external) score

Rating

0 out of 5 Stars 0 Review

5 Stars
 
0.00%
4 Stars
 
0.00%
3 Stars
 
0.00%
2 Stars
 
0.00%
1 Star
 
0.00%

About

  • There are no comments yet

Thank you! Review submitted.

Ok