2.1 · Color

Colors that match your eyes: oklch()

Pick colors by perceived lightness, chroma and hue, so palettes stay even.

oklch(L C H) describes a color by lightness (0 to 1), chroma (colorfulness, 0 to about 0.37) and hue (0 to 360 degrees). Unlike HSL, the lightness is perceptual. Two colors with the same L look equally light, so you can rotate the hue and keep contrast predictable.

It also reaches the wider P3 gamut of modern screens. If a color is out of range for a display, the browser maps it to the closest one it can show.

Before
/* Both "50% lightness" */
--yellow: hsl(60 100% 50%);  /* glaring */
--blue: hsl(240 100% 50%);   /* dark */
Now
/* Same L, same perceived lightness */
--yellow: oklch(0.7 0.15 100);
--blue: oklch(0.7 0.15 260);