Skip to content

Evaluate whether two colors have sufficient contrast to pass WCAG requirements.

Notifications You must be signed in to change notification settings

misund/passes-wcag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Greenkeeper badge Build Status

Passes WCAG

Evaluate whether two colors have sufficient contrast to pass WCAG requirements.

Doesn't handle transparency as of yet.

Installation

npm i passes-wcag

Usage

import {
  passesWcagAaLargeText,
  passesWcagAa,
  passesWcagAaa,
} from 'passes-wcag';

passesWcagAa('black', '#fff'); // true
passesWcagAaLargeText('rgb(1, 1, 1)', 'rgb(250, 248, 247)') // true
passesWcagAaa('black', 'rgb(0, 0, 0)') // false

Signature

passesWcagAaLargeText(color1: string, color2: string) => boolean
passesWcagAa(color1: string, color2: string) => boolean
passesWcagAaa(color1: string, color2: string) => boolean

Contributing

I appreciate your issues and PRs on Github!

Testing

yarn build && yarn test

Releasing

This project uses np.

  1. Make sure your changes are in master
  2. Run yarn release
  3. Follow the interactive release guide

About

Evaluate whether two colors have sufficient contrast to pass WCAG requirements.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors 4

  •  
  •  
  •  
  •