Skip to content

unplugstudio/wcag-contrast

Repository files navigation

WCAG Contrast Build Status

Utilities to work with WCAG color contrast

Install

$ npm install wcag-contrast

Sass

@function luminance

Determine the luminance of a color (between 0 and 1) according to the WCAG algorithm

  • Group: General
  • Access: public

Parameters

Name Type Description Default
$color Color Color -

Returns

Number Luminance: 1 is pure white, 0 is pure black

Dependents

  • @function contrast Calculate the contrast ratio between two colors
  • @function contrast Calculate the contrast ratio between two colors

Links

@function contrast

Calculate the contrast ratio between two colors

  • Group: General
  • Access: public

Parameters

Name Type Description Default
$back Color Background color -
$front Color Foreground (text) color -

Returns

Number The relative contrast of both colors

Dependencies

Dependents

  • @function choose-contrast-color Determine whether to use dark or light text on top of given color
  • @function choose-contrast-color Determine whether to use dark or light text on top of given color

Links

@function choose-contrast-color

Determine whether to use dark or light text on top of given color

  • Group: General
  • Access: public

Parameters

Name Type Description Default
$color Color Background color -
$contrast Number How much contrast is considered enough 4.5
$prefer-white Boolean Prefer white when both black and white have enough contrast true

Returns

Color #fff or #000

Dependencies

Links

About

Utilities to work with WCAG color contrast

Resources

License

Stars

Watchers

Forks

Packages

No packages published