CKTIS / CSS
oklch(): polar coordinates for Oklab
Adjust perceptual lightness, chroma and hue in the polar form of Oklab.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
color: oklch(60% 0.1 30deg / 0.5);oklch() is the polar representation of Oklab. It uses lightness L, chroma C and hue angle H instead of the rectangular a and b axes. A lightness of 60% is equivalent to 0.6. Chroma is a distance from the neutral axis, not an HSL saturation percentage, so moving an HSL value into this position does not preserve its meaning.
At zero chroma the color is neutral and changing the hue angle has no visible effect. Increasing chroma adds colorfulness, but the available range depends on lightness, hue and the output gamut; there is no single chroma setting that is guaranteed to fit every display. Optional alpha after a slash controls how the color is composited over what lies behind it.
The example paints two oklch(60% 0 ...) colors with different hue angles and obtains the same gray around RGB 128,128,128. A nonzero-chroma sample produces a colored pixel, and half alpha over white produces a lighter mixture. The white background is explicit, because the resulting RGB value of a translucent color cannot be specified independently of its backdrop.
Examples
const sample=async style=>{const svg='<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8"><rect width="8" height="8" fill="white"/><foreignObject width="8" height="8"><div xmlns="http://www.w3.org/1999/xhtml" style="width:8px;height:8px;'+style.replaceAll('&','&').replaceAll('"','"')+'"></div></foreignObject></svg>';const image=new Image();image.src='data:image/svg+xml;charset=utf-8,'+encodeURIComponent(svg);await image.decode();const canvas=document.createElement('canvas');canvas.width=canvas.height=8;const context=canvas.getContext('2d');context.drawImage(image,0,0);return [...context.getImageData(4,4,1,1).data].slice(0,3).join(',')};
const gray0=await sample('background:oklch(60% 0 0deg)');
const gray240=await sample('background:oklch(60% 0 240deg)');
const color=await sample('background:oklch(60% 0.1 30deg)');
const alpha=await sample('background:oklch(60% 0.1 30deg / 50%)');
console.log('zero-chroma='+gray0+'/'+gray240+'; color='+color+'; alpha-over-white='+alpha);Result
zero-chroma=128,128,128/128,128,128; color=180,104,92; alpha-over-white=217,179,173
The two gray samples isolate hue independence at zero chroma; the final sample separately demonstrates alpha compositing.