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 brand color can look uneven when its hue changes: some hues appear brighter than others even when their HSL lightness stays fixed. OKLCH makes hue adjustments while keeping perceived brightness more consistent. It also gives you separate controls for building lighter, darker, or more vivid variants. section 7.1.4

The CSS function oklch(L C H) uses three coordinates:

  • Lightness (L) runs from 0 for black to 1 for white; percentages also work. section 7.1.4
  • Chroma (C) measures intensity: 0 is gray, while higher values are more vivid. Its usable upper end depends on hue and lightness. section 7.1.4
  • Hue (H) is an angle around the color wheel, from 0 to 359 degrees. section 7.1.4

Style a heading

h1 { color: oklch(0.42 0.2 328); } sets its lightness, chroma, and hue in that order. To make a scale, hold hue and chroma steady while changing lightness; to change vividness, hold lightness and hue steady while changing chroma. section 7.1.4

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 CSS backgrounds with the same chroma and hue. Only lightness changes, producing light, medium, and dark brand variants. section 7.1.4

For a dark-mode starting point, invert lightness with Ldark = 1 − L while retaining chroma and hue. A paired palette may also reduce chroma and shift hue slightly; test each resulting color against its new background for contrast. Check colors on regular monitors, too: some OKLCH values that display on Display P3 screens will not work on less capable displays. section 7.5.2 section 7.5.4 section 7.1.4

How Math for Web Design covers it

How deep it goes
Defines lightness, chroma, and hue with CSS values, then applies them to scales and palette transformations without detailing color-space conversion algorithms.
Examples
Shows a colored heading, lightness and chroma scales, a vivid green value, and a JavaScript lightness-inversion function.
What you can do after
Apply it via CSS oklch() to create color variants, and evaluate dark-mode pairs for contrast and display compatibility.
How it connects
Connects OKLCH to HSL, LAB, dark mode, Display P3, and color contrast.

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.