@ajberkow/color-contrast

A utility to check for WCAG compliant color contrast

Usage no npm install needed!

<script type="module">
  import ajberkowColorContrast from 'https://cdn.skypack.dev/@ajberkow/color-contrast';
</script>

README

color-contrast

============== A small utility to calculate color contrast and determine WCAG compliance. This tool is based on the WebAIM color contrast checker. It uses calculations based on the W3C Web Content Accessibility Guidelines.

oclif Version Downloads/week License

Usage

TODO

Commands

Commands take the format color-contrast [-f <foreground hex value>] [-b <background hex value>]. Foreground and background values can be entered with or without # signs. The default values are

  • foreground: #000000
  • background: #ffffff

A report is generated for each ratio. For example, entering this command color-contrast -f #123abc returns

{
    "ratio": 8.909214716654146,
    "AA": "pass",
    "AALarge": "pass",
    "AAA": "pass",
    "AAALarge": "pass"
}

TODO

  • Tests
  • Other kinds of color formatting (e.g. rgb, hsl) and possibly transparency