oklab() CSS Function
The oklab() function defines a color by lightness and two color axes in the Oklab color space, which is good for smooth gradients and mixing.
Description
The oklab() CSS function defines a color in the Oklab color space using a lightness value and two color axes, a (green to red) and b (blue to yellow). Oklab was created as an improved version of CIE lab(): it predicts perceived lightness, chroma and hue more accurately, especially for saturated blues, while remaining simple to calculate.
Lightness is a number from 0 (black) to 1 (white), or a percentage. The a and b axes are signed numbers that usually stay between about -0.4 and 0.4, where 100% equals 0.4. Setting both to 0 gives a neutral gray. Colors outside the screen's gamut are mapped to the nearest displayable color, and an optional alpha value can follow a slash.
.surface {
background-color: oklab(97% 0 0); /* near-white neutral */
}
.danger {
background-color: oklab(60% 0.18 0.09); /* red */
}
.info {
background-color: oklab(60% -0.05 -0.15); /* blue */
}
/* Smooth gradient with no muddy midpoint */
.hero {
background: linear-gradient(in oklab to right, #ff0080, #00c3ff);
}
Oklab is the default interpolation space for many modern CSS features, such as gradients written with in oklab and color-mix(), because mixing in it produces even, natural-looking transitions. Its polar form, oklch(), is usually easier to write by hand.
Interactive Demo
Syntax
oklab() = oklab( [ from <color> ]? [ <percentage> | <number> | none ]
[ <percentage> | <number> | none ]
[ <percentage> | <number> | none ]
[ / [ <alpha-value> | none ] ]? )
Values
- L (lightness)A <number> from 0 to 1 or a <percentage> from 0% to 100%. 0 is black and 1 (100%) is white.
- aA <number> or <percentage> for the green-red axis. Negative values are greener, positive values redder. 100% equals 0.4.
- bA <number> or <percentage> for the blue-yellow axis. Negative values are bluer, positive values more yellow. 100% equals 0.4.
- alphaOptional. An <alpha-value> after a slash (/) from 0 to 1, or a percentage.
Example
Browser Support
The following information will show you the current browser support for the CSS oklab() function. Hover over a browser icon to see the version that first introduced support for this CSS function.
Desktop





Tablets & Mobile





