is-readable-color

1.0.1 • Public • Published

Is Readable Color

A npm module that determines if a text color is readable in contrast with a background color

Usage

To use this function, you can call it like this:

import isReadableColor from "is-readable-color";
const textColor = '#000000'; // Black
const bgColor = '#ffffff'; // White

if (isReadableColor(textColor, bgColor)) {
  console.log('The text color is readable.');
} else {
  console.log('The text color is not readable.');
}

Also a text size optional parameter is accepted, default is 18

isReadableColor(textColor, bgColor, 12)

Package Sidebar

Install

npm i is-readable-color

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

2.68 kB

Total Files

3

Last publish

Collaborators

  • rodrigoitj