Oklab and Oklch: Modern Perceptual Color Spaces
HSL is intuitive but lies about brightness. CIELAB is honest but clumsy in blue and needs elaborate patches. In 2020 a single, elegant space arrived that is both intuitive and perceptually well-behaved - and modern CSS adopted it almost overnight. This is the complete, interactive tour of Oklab and its polar twin Oklch: why they exist, the math that makes them work, and the everyday problems they finally solve.
Advanced Oklch production lab
Oklch is more than a nicer color picker. In production it becomes a decision surface: which chroma can survive the target gamut, how much lightness can move before contrast breaks, whether a gradient should travel through Oklab or Oklch, and how stable a palette remains when you ask for many steps. This lab turns those hidden decisions into live data.
Analyze gamut mapping, interpolation, tonal ramps, contrast, and perceptual distance
Pick a base color, then edit the Oklch coordinates and production context. The canvas plots the a/b plane, gamut boundary search, tonal ramp, interpolation path, and contrast risk. The meters explain whether the current request is safe for CSS tokens, gradients, dark mode, or brand palettes.
The problem with "intuitive" spaces
There are two families of color space, and until recently you had to pick a side. The intuitive family - HSL, HSV - lets a human reason in plain words but is just sRGB twisted into a cylinder, so its numbers do not match perception. The perceptual family - CIELAB and friends - is built on real vision science but is awkward to author in and has well-known weak spots, especially a hue that drifts in the blues.
Three failures show up again and again when the wrong tool is used. First, lightness lies: a blue at HSL L = 50% looks far darker than a yellow at the same number. Second, lightening shifts hue: push a blue lighter in sRGB or HSL and it slides toward purple. Third, gradients misbehave: blend blue to yellow in sRGB and the midpoint goes a muddy gray. Each of these is a perceptual-uniformity problem, and each is exactly what Oklab was built to fix.
What Oklab is
Oklab was published in December 2020 by Björn Ottosson, who set out to build "a better Lab" optimized specifically for the kinds of operations software performs on color: blending, lightening, generating palettes. Rather than starting from the 1931 CIE machinery, he started from an approximation of the cone responses (the L, M, S signals the eye actually produces), applied a cube-root nonlinearity to model the compressive response of vision, and then fit a final linear transform so that hue lines stayed straight and lightness matched perception.
The result keeps the shape of CIELAB - an opponent space with a lightness axis and two color axes - but corrects CIELAB's biggest practical flaw: it does not bend hue as colors get lighter or more saturated. And because the whole transform is two small matrix multiplies with a cube root in between, it is cheap enough to run per pixel, in shaders, and live in a browser.
The Oklab axes
Oklab describes a color with three Cartesian numbers, mirroring CIELAB's structure but on its own, better-tuned scale:
Neutral grays sit at a = b = 0 for every lightness, exactly as in an opponent model of vision. The further (a, b) gets from the origin, the more colorful the result. That distance has a name - chroma - and turning the Cartesian (a, b) into a radius and angle is precisely what gives us Oklch.
Oklch: the designer-friendly form
Oklch is Oklab in polar coordinates. The lightness L is unchanged; the two color axes become a radius and an angle:
This is the same trick that turns CIELAB into LCh, or that turns the RGB cube into HSL - but here the axes are perceptual, so the three dials finally mean what you expect. Raising L makes it lighter without changing the color. Raising C makes it more colorful without changing the hue. Spinning h rotates through hues that feel evenly spaced. It is the ergonomics of HSL with the integrity of a perceptual space.
Three perceptual dials - and a gamut warning
Set lightness, chroma, and hue. The swatch is the nearest sRGB color and the badge tells you whether your request actually fits inside sRGB. Push chroma high at a mid lightness and watch many hues fall out of gamut - Oklch can describe colors your screen cannot show, which is a feature, not a bug.
Hue constancy: the headline win
The single most quoted reason to use Oklch is hue constancy. Take any color and make a row of lighter and darker versions. In HSL - and in naive sRGB - the hue wanders: blues drift toward purple as they lighten, and the steps look uneven, bunching up at the dark end. In Oklch, the hue stays put and the steps feel evenly spaced. That is the difference between a tonal ramp that looks designed and one that looks broken.
The same hue, ramped in HSL versus Oklch
Both rows hold one hue and step from dark to light. The HSL row fixes saturation and walks lightness; the Oklch row fixes chroma and walks perceptual lightness. Watch the HSL row twist toward purple and crowd at the dark end, while the Oklch row stays the same color and steps evenly.
The conversion pipeline
Getting from an sRGB byte triple to Oklab is a fixed four-step pipeline. Nothing in it is tuned per color - it is the same constants every time.
The inverse simply runs backward: Oklab → cube (the inverse of the cube root) → inverse matrices → delinearize. Because every step is invertible, the round trip is exact up to floating-point and the final 8-bit rounding.
Gradients done right
Interpolation is where the space you choose becomes visible to everyone, not just color nerds. Blend two colors by walking a straight line between them - the question is which space the line lives in. sRGB interpolation dips dark and muddy through the middle. HSL interpolation swings through unwanted hues. Oklab interpolation keeps lightness and colorfulness sensible the whole way across.
The same two endpoints, interpolated in three spaces
Pick two colors. The three bars blend them in sRGB, in HSL (shortest hue arc), and in Oklab. The classic test is blue → yellow: sRGB grays out in the middle, HSL detours through green, and Oklab stays bright and even. Try saturated complementary pairs to see the gap most clearly.
This is exactly why CSS Color 4 lets you name the interpolation space:
linear-gradient(in oklab, …) and
color-mix(in oklch, …) produce the clean blends by default in modern browsers.
Perceptual lightness and palettes
Because Oklab's L tracks perceived lightness, it is the natural engine for a tonal scale - the 50-to-900 ramp every design system needs. Fix the hue and chroma, step lightness in even increments, and you get a scale whose steps look even and whose endpoints behave. It also makes accessible contrast far more predictable: two colors with a sensible gap in Oklab lightness will usually have a sensible contrast ratio, because both are anchored in perception.
Build a 50–900 ramp from one hue
Choose a hue and a target chroma. The generator steps perceptual lightness from light to dark, reducing chroma automatically where a step would fall out of the sRGB gamut. The result is the kind of even, hue-stable scale you would ship as design tokens.
Oklch in CSS Color 4
Oklab and Oklch are first-class CSS color functions, shipping in every major browser since 2023. The syntax mirrors the model directly:
That last line - relative color syntax - is the payoff. You can derive a hover or disabled variant by nudging only L, confident the hue and chroma stay put. The whole "lighten by 8%" intent becomes a single, honest expression that would have been a hue-shifting mess in HSL.
none and percentages are
allowed too.Oklab vs CIELAB vs HSL
Each space is the right answer to a different question. The converter below shows one color in all of them at once; the table sums up when to reach for which.
See sRGB, HSL, Oklab, and Oklch side by side
Pick or type a color, or tap a preset. The panel reports it as RGB, HSL, Oklab (L a b), and Oklch (L C h) simultaneously, with a gamut flag. It is the fastest way to build intuition for how Oklch lightness and chroma relate to the HSL numbers you already know.
- RGB
- 42, 157, 143
- HSL
- 173°, 58%, 39%
- Oklab
- 0.630, -0.101, -0.005
- Oklch
- 63.0%, 0.101, 183°
| Need | Best space | Why |
|---|---|---|
| Quick casual tweak | HSL / HSV | Fastest to reason about; perceptual error does not matter for a one-off nudge. |
| Even tonal ramps & theming | Oklch | Perceptual lightness, hue constancy, native in CSS - the modern default. |
| Smooth gradients / blends | Oklab | Straight-line interpolation stays bright and even, no gray midpoint. |
| Industry color difference (ΔE) | CIELAB / CIEDE2000 | The standardized, contract-grade reference the whole industry already uses. |
| Absolute measurement & profiles | CIE XYZ / Lab | Tied to the standard observer and reference whites; the metrological ground truth. |
Limits and caveats
Test your understanding
Six questions on Oklab and Oklch. Instant feedback, no scores recorded - a wrong answer comes with a short explanation pointing you back to the right section.
Quick check
Continue your journey
These articles sit directly around Oklab - the spaces it improves on and the ones it works alongside. The numbers reflect each article's position in the editorial roadmap of 113.
Dark Mode and Adaptive Color
Re-tuning accent lightness for dark backgrounds, the Oklch way.
Digital · 27Color Gradients and Interpolation
Oklch put to work: the best-behaved gradients blend right here.
Design · 24Color Theory and Harmony
Run these harmony angles in Oklch and the schemes stay perfectly balanced.
Digital · 21HSL, HSV, and HSB: The Cylindrical Color Models
The intuitive models Oklch keeps the shape of - and fixes the perception of.
Colorimetry · 09CIELAB and LCH Explained
The perceptual space Oklab was designed to improve on, especially in the blues.
Computational · 20ΔE Metrics from CIE76 to CIEDE2000 and ΔEITP
Color difference - where CIELAB still rules and Oklab is the modern challenger.
Colorimetry · 08CIE XYZ Explained
The tristimulus hub every space, Oklab included, is ultimately defined against.
Digital · 12RGB, sRGB, Adobe RGB, ProPhoto, Display P3, Rec.2020
The gamuts Oklch can exceed - and why gamut mapping matters.
Design · 13Accessible Color Design and WCAG Contrast
Oklab lightness helps, but contrast has its own rules - here they are.