liveBook · Manning

OKLCH

As explained in Math for Web Design

OKLCH is a perceptually uniform color space that represents color using lightness, chroma, and hue.

A color scale often looks uneven when shades share an HSL lightness value but do not look equally bright. OKLCH addresses that problem by describing color in perceptual terms: lightness, chroma, and hue. It keeps hue-based color selection intuitive while making changes more consistent to the eye. section 7.1.4 section 7.8

OKLCH is a polar coordinate system with three components. L is perceived brightness, from 0 or 0% (black) to 1 or 100% (white). C is chroma: distance from neutral gray, where 0 is grayscale and roughly 0.4–0.5 can be highly saturated depending on hue and lightness. H is hue, an angle from 0 to 359 degrees. Unlike HSL, rotating OKLCH hue maintains perceived brightness. section 7.1.4

Set a heading color

Use CSS oklch() as oklch(lightness chroma hue). An optional slash adds alpha. h1 { color: oklch(0.42 0.2 328); } A half-transparent version is oklch(0.42 0.2 328 / 0.5). section 7.1.4

For a predictable scale, hold chroma and hue constant while varying lightness. This produces lighter and darker versions of one color identity. Conversely, hold lightness and hue constant while varying chroma to create subtle, vibrant, and highly intense variants. section 7.1.4 section 7.8

Listing 7.1 Creating a color scale by varying lightness in the OKLCH color space
.brand-light   { background: oklch(0.8 0.15 350); }
.brand-medium  { background: oklch(0.6 0.15 350); }
.brand-dark    { background: oklch(0.4 0.15 350); }

Compare three brand shades that retain the same chroma and hue while lightness changes. section 7.1.4

OKLCH is also useful for dark-mode transformations. Invert lightness with 1 − L while preserving chroma and hue for a perceptually consistent opposite brightness; a fuller palette transformation can then reduce chroma, apply a small hue shift, and test contrast against the new background. section 7.5.2 section 7.5.4

Check results on regular monitors when broad compatibility matters. Some OKLCH colors are available on wide-gamut Display P3 screens but may fail on less capable displays. section 7.1.4

How Math for Web Design covers it

How deep it goes
Defines all three coordinates, their practical ranges, CSS syntax, scale variations, and lightness inversion without deriving color-space conversion algorithms.
Examples
Uses heading colors, fixed-hue lightness and chroma scales, and inverted-lightness dark-mode colors.
What it assumes
Introduces OKLCH coordinates directly while assuming familiarity with CSS color declarations and basic light/dark theme work.
What you can do after
Apply it via CSS oklch() to create controlled color scales and derive perceptually consistent dark-mode variants.
How it connects
Connects OKLCH with HSL, LAB, Display P3, dark mode, CSS custom properties, media queries, and contrast ratios.

Also explained in

Compare how 2 books explain OKLCH →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Math for Web Design. The section links point to the parts of the book it draws on.