Under The Hood
frontend css CSS Color 4 (oklch/oklab, Chrome 111+, Safari 15.4+)

OKLCH Color Space: Perceptual Uniformity & Display P3

Last updated
Prerequisites:
CSS colors (hex, rgb, hsl)
Understanding of color models and the sRGB gamut
  • css
  • color
  • oklch
  • color-space
  • display-p3
  • wide-gamut

Read at your depth

The practical view

oklch() is a color function with three channels: lightness (L), chroma (C — how vivid), and hue (H — the color angle). background: oklch(70% 0.15 250);. Unlike hex/hsl, oklch is perceptually uniform: equal numeric steps look like equal visual steps. To make a palette, keep L constant and rotate H, or keep H constant and step C. It also exposes colors outside sRGB: you can specify wide-gamut colors for Display P3 screens (use color(display-p3 r g b) or just oklch values that exceed sRGB chroma), letting high-end monitors show richer colors with graceful fallback.

The same idea in other frameworks

react equivalent
Design-token systems in React apps (Tailwind v4, CSS vars) increasingly use oklch for theme ramps and interpolation.

Legacy vs modern

HSL hand-tuned palette vs OKLCH generated palette

HSL lightness is not perceptually uniform — equal steps look uneven; OKLCH lightness steps look visually even, so palettes are predictable.

before → after
HSL palette with hand-tuning
--c-500: hsl(210 80% 50%); /* ❌ OLD: equal lightness steps do NOT look even */
OKLCH generated palette
--c-500: oklch(55% 0.16 250); /* ✅ NEW: even perceptual steps */

Interview gotchas

Context

This tests whether you understand perceptual uniformity — the actual math behind why HSL ramps look uneven — rather than just repeating 'OKLCH is modern'.

The mechanical answer

HSL's lightness channel is a simple model that does not match human perception: two colors with the same HSL lightness can appear very different in brightness, and equal lightness steps look uneven (especially in the mid-tones and for saturated colors). Interpolating in HSL between two colors passes through desaturated grey midpoints because hue and saturation are treated as a naive cylinder. OKLCH is built on a perceptually-uniform model (CAM16-UCS-derived): equal numeric steps in L correspond to equal perceived lightness differences, and chroma/hue interpolation keeps colors vivid through the whole gradient. This makes generated ramps and gradients predictable and consistent, which is why design systems have migrated to it.

Trap

The naive answer is 'OKLCH just has nicer color names or more channels'. The difference is the perceptual model behind the numbers. Another trap: assuming any color space interpolates identically — color-mix(in hsl, ...) vs color-mix(in oklch, ...) produce visibly different gradients, and the in-hsl one muddies. Candidates who mention perceptual uniformity and interpolation space selection show real understanding.

Under The Hood — a multi-depth technical interview hub.

Third-party licenses Press ⌘ K to search.