chromatic-luminance

1.0.1 • Public • Published

chromatic-luminance

Build Status Coverage Status code style: prettier jest

Lightweight (no dependencies) and fast color brightness detector based on the w3 documentation for color luminance: https://www.w3.org/TR/WCAG20/#relativeluminancedef. Answers question: dark-background -> use light text OR light-background -> use dark text.

Installation

yard add chromatic-luminance or npm install chromatic-luminance

API

/*
 * Returns True/False if color is considered 'dark' or not by W3 luminance standards
 * @param {color} can be shorthand hex (e.g. '#000'), normal hex (e.g. '#000000') or HTML named colors (e.g. 'black')
 */
default function isDark(color: string): boolean;

Test

yarn test or npm run test

License

MIT

Package Sidebar

Install

npm i chromatic-luminance

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

14.5 kB

Total Files

10

Last publish

Collaborators

  • hansjhoffman