@kurkle/color
@kurkle/color parses CSS color strings and lets you read, convert and manipulate the
result through a small Color class. It supports hex, named colors, rgb(), hsl(),
hwb(), hsv() and oklch().
Install
Section titled “Install”npm install @kurkle/colorFirst example
Section titled “First example”import { Color } from "@kurkle/color"
const color = new Color("oklch(0.7 0.15 200)")
color.valid // truecolor.hexString() // "#00B9C3"color.darken(0.2).rgbString() // "rgb(0, 148, 156)"See Parsing for every supported syntax, Formatting for
turning a color back into a string, and Transforming for the mutating
methods like mix, lighten and rotate.