Colore JS

Search documentation

Find a function or jump to a section.
v2.0.1

saturate

saturate makes a color more vivid by increasing OKLCH chroma. It keeps lightness and hue, which lets you strengthen an accent without choosing a new color.

Example

import { colore } from 'colore-js';
import { saturate } from 'colore-js/fn';

colore('#64836a').saturate(20).css(); // '#5f8567'
saturate('#64836a', 20); // '#5f8567'

Syntax

colore(color).saturate(amount: number): Color
saturate(color: ColorInput, amount: number): string

Parameters

NameTypeDescription
colorColorInputAny supported CSS color, tagged color object, Color instance or packed RGB number.
amountnumberPercentage of the current chroma to add. Pass 20 for a 20% increase and 100 to double chroma.

Returns

The method returns a new Color. The standalone function returns hex in sRGB, Display P3 for a wider result, or OKLCH when neither gamut fits.

Throws

A ColorError if the color is invalid or the amount is outside 0–100, nonfinite, or strictly between 0 and 1.

Make a wide-gamut accent more vivid

The CSS result can move past the range of hex or Display P3. Keep the returned OKLCH string if that fits your output target.

import { saturate } from 'colore-js/fn';

saturate('oklch(0.7 0.3 150)', 20); // 'oklch(0.70000 0.36000 150.00)'

Saturating a neutral gray leaves it neutral because its chroma is zero. To tint a gray, set both chroma and hue with setOklch.