Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

wcag-contrast

1.2.0 • Public • Published

wcag color constrast

Build Status Greenkeeper badge

WCAG contrast ratio measurement and scoring.

API

luminance

Get the contrast ratio between two relative luminance values

Parameters

Examples

luminance(1, 1); // = 1

Returns number 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 contrast ratio

hex

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

Parameters

Examples

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

Returns number contrast ratio

score

Get a textual score from a numeric contrast value

Parameters

Examples

score(10); // = 'AAA'

Returns string score

install

npm i wcag-contrast

Downloadsweekly downloads

446

version

1.2.0

license

BSD-2-Clause

repository

githubgithub

last publish

collaborators

  • avatar