← All packages

@lacspace/color

v1.0.2App & Utils Kit0 deps

Parse, convert, manipulate and check colours — hex/rgb/hsl, lighten/darken/mix/alpha, and WCAG contrast for accessible palettes. Zero-dependency, isomorphic.

npm i @lacspace/color

Usage

color.ts
import { toHsl, lighten, mix, alpha } from "@lacspace/color";

toHsl("#ff0000");            // "hsl(0, 100%, 50%)"
lighten("#2563eb", 15);      // a lighter blue
mix("#000000", "#ffffff");   // "#808080"
alpha("#2563eb", 0.2);       // "rgba(37, 99, 235, 0.2)"

Exports 19

alphacontrastdarkendesaturategrayscalehslToRgbisDarkisReadablelightenluminancemixparsereadableTextColorrotatesaturatetoHextoHsltoHslObjecttoRgb

Keywords

colorcolourhexrgbhslwcag

More in App & Utils Kit