@pbroom/color-kitManipulation

desaturate

Decrease chroma by a relative amount: c * (1 - amount), clamped below at 0. There is no upper cap, so amount = 0 returns the input chroma unchanged even for wide-gamut colors above 0.4. Lightness, hue and alpha are unchanged.

functionimport { desaturate } from '@pbroom/color-kit';index.ts:114
function desaturate(  color: Color, ,  amount: number,): Color;

Parameters

colorColor
Color to desaturate
amountnumber
Fraction of the chroma to remove (0-1)

Returns

ColorA new Color

Example

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

desaturate(parse('oklch(0.7 0.2 250)'), 0.5); // → { l: 0.7, c: 0.1, h: 250, alpha: 1 }

See also