oklch() CSS Function
The oklch() function defines a color by lightness, chroma and hue in the OKLCH color space, which keeps perceived lightness consistent across hues.
Description
The oklch() CSS function defines a color in the OKLCH color space using lightness, chroma and hue. OKLCH is the cylindrical form of oklab(), a modern perceptual color space that improves on CIE Lab and lch(). Its biggest advantage is that changing the hue keeps colors looking equally light and equally saturated, and blues no longer drift toward purple, which makes it one of the best spaces for building design system palettes.
Lightness is a number from 0 (black) to 1 (white), or a percentage from 0% to 100%. Chroma is the amount of color, from 0 (gray) to about 0.4 for the most vivid colors; 100% equals 0.4. Hue is an angle in degrees. OKLCH can describe colors beyond sRGB, including wide-gamut P3 colors; if the screen cannot display a color, the browser maps it to the nearest displayable one. An optional alpha value can be added after a slash.
:root {
--brand: oklch(62% 0.19 255);
}
.button {
background-color: var(--brand);
}
/* Lighter and darker steps that keep the same hue */
.button:hover { background-color: oklch(from var(--brand) calc(l + 0.08) c h); }
.button:active { background-color: oklch(from var(--brand) calc(l - 0.08) c h); }
/* A matching accent with the same lightness and chroma */
.accent {
color: oklch(62% 0.19 145);
}
Because equal steps in OKLCH look equal to the eye, it is well suited for generating tints and shades, for accessible contrast work, and as an interpolation space for gradients, for example linear-gradient(in oklch, ...).
Interactive Demo
Syntax
oklch() = oklch( [ from <color> ]? [ <percentage> | <number> | none ]
[ <percentage> | <number> | none ]
[ <hue> | 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.
- C (chroma)A <number> or <percentage> for the amount of color. 0 is gray; 100% equals 0.4. Values are theoretically unbounded but rarely exceed 0.5.
- H (hue)A <hue> (number of degrees or <angle>) giving the position on the color wheel.
- 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 oklch() function. Hover over a browser icon to see the version that first introduced support for this CSS function.
Desktop





Tablets & Mobile





