@pbroom/color-kitManipulation

grayscale

Remove all chroma (c = 0), keeping OKLCH lightness, hue and alpha, so the gray has the same perceived lightness as the input.

functionimport { grayscale } from '@pbroom/color-kit';index.ts:297
function grayscale(color: Color): Color;

Parameters

colorColor
Color to desaturate fully

Returns

ColorA new Color

Example

TypeScript
import { grayscale, parse, toHex } from '@pbroom/color-kit';

toHex(grayscale(parse('oklch(0.7 0.15 30)'))); // → '#9e9e9e'

See also