0.0.4 • Published 5 months ago

accessible-color v0.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

accessible-color

Generate color from contrast.

Install

npm install accessible-color

Usage

import { gray, color } from 'accessible-color';
import { formatHex } from 'culori';

// Gray with WCAG Contrast 7 on white background
console.log(formatHex(gray('white', 7))); // => #595959

// Gray with WCAG Contrast 7 on black background
console.log(formatHex(gray('black', 7))); // => #959595

// Blue with WCAG Contrast 4.5 on white background
console.log(formatHex(color('white', 4.5, 255))); // => #2477d5

// Red with WCAG Contrast 4.5 on black background
console.log(formatHex(color('black', 4.5, 25))); // => #de2c34

The color returned by these functions are not stable. But the contrast rate is guaranteed. The algorithm will be updated.

0.0.4

5 months ago

0.0.3

5 months ago

0.0.2

5 months ago

0.0.1

1 year ago