OKLab
The perceptually uniform Cartesian color space behind OKLCH. Designed by Björn Ottosson in 2020 to be simpler and more accurate than CIE Lab.
oklab(0.53 -0.10 -0.23).The three axes
L — Lightness
Ranges from 0 (black) to 1 (white). Because OKLab is perceptually uniform, equal steps in L produce equal perceived changes in brightness, regardless of hue.
a — Green–red axis
Negative values lean green, positive values lean red. Ranges roughly from −0.4 to +0.4 in sRGB. The a axis is orthogonal to b — moving along a does not change the perceived hue on the b axis.
b — Blue–yellow axis
Negative values lean blue, positive values lean yellow. Ranges roughly from −0.4 to +0.4 in sRGB. Together with a, it forms the plane of chromatic variation at a given lightness.
OKLab vs OKLCH
OKLab and OKLCH are related by a polar-to-Cartesian transformation. The conversion is:
From OKLab to OKLCH:
C = √(a² + b²)
H = atan2(b, a) × 180 / π
From OKLCH to OKLab:
a = C × cos(H × π / 180)
b = C × sin(H × π / 180)
The color is identical — only the coordinate system changes. OKLab is preferred when interpolating (gradients, animations) because the Cartesian axes avoid the hue-rotation issues that polar spaces can produce. OKLCH is preferred when reasoning about colors manually because "hue + chroma + lightness" maps to how designers think.
Why OKLab was created
CIE Lab (1976) is the classic perceptually uniform color space, still widely used in color science. But it has two practical problems:
- Complex formulas. CIE Lab involves a cube-root function, several matrix multiplications and a piecewise linear fit for low luminances.
- Blue-region distortion. The perceptual uniformity of CIE Lab breaks down in the blue-purple region, producing hues that appear too similar or too saturated when generated algorithmically.
OKLab addresses both. It is mathematically simpler (two matrix transformations plus a cube root) and handles the blue region much more evenly. This makes it ideal for real-time applications, color pickers, and design systems.
Practical examples
Interpolating two colors
To mix two colors smoothly, convert them to OKLab, linearly interpolate L, a and b, then convert back to sRGB. This produces smoother gradients than interpolating in sRGB or HSL.
Distance between colors
The Euclidean distance between two OKLab colors correlates well with perceived difference. This makes it useful for palette matching, image quantization and finding the closest color in a set.
Adjusting lightness without changing hue
Change only the L axis. The a and b axes stay the same, so the hue and saturation do not shift — a common problem when adjusting lightness in other spaces.
Practical syntax in CSS
/* OKLab syntax */
color: oklab(0.53 -0.10 -0.23);
/* With alpha */
color: oklab(0.53 -0.10 -0.23 / 0.5);
/* Adjusting lightness without changing hue */
color: oklab(0.3 -0.10 -0.23);
color: oklab(0.7 -0.10 -0.23);
When to use OKLab
- Gradient interpolation — smoother transitions than sRGB or HSL.
- Color distance — for finding the nearest color in a set.
- Color mixing — perceptually even mixing between any two colors.
- Image processing — where perceptual uniformity matters for quantization or matching.
Continue reading
Frequently asked questions
What is OKLab?
OKLab is a perceptually uniform color space designed by Björn Ottosson in 2020. It uses three axes: L for lightness, a for the green-red axis, and b for the blue-yellow axis. It was designed to be simple, fast and more accurate than older color spaces.
What is the difference between OKLab and OKLCH?
OKLab and OKLCH describe the same color space in two different coordinate systems. OKLab is Cartesian (L, a, b); OKLCH is polar (L, C, H). Both give identical colors; OKLab is easier to interpolate, OKLCH is more intuitive for designers.
Why was OKLab created?
OKLab was designed to fix shortcomings in existing perceptual color spaces. CIE Lab, while accurate, is complex to compute and sometimes produces unusual results in the blue region. OKLab is simpler, faster, and handles hues more evenly across the visible spectrum.
When should I use OKLab instead of OKLCH?
Use OKLab when you are interpolating colors (gradients, animations) because the Cartesian form interpolates more smoothly. Use OKLCH when you are reasoning about hue, chroma, or building palettes manually, because its polar form is more intuitive.
Is OKLab supported in browsers?
Yes. oklab() is part of the CSS Color Module Level 4 and is supported in all modern browsers — Chrome, Edge, Safari and Firefox — alongside oklch().