OKLCH
CSS Color
Design Tokens
Color Gamut

OKLCH Color Palettes for UI: Lightness, Gamut and Contrast

Build a predictable UI color scale in OKLCH, convert in-gamut colors to sRGB, and test fallbacks against the surface they actually sit on.

ColorIndicator Academy
7 min read
Published

Turn a bright HSL yellow into blue without changing its displayed lightness number. It gets much darker. HSL lightness is based on the extremes of the RGB channels, so identical values need not look equally light. OKLCH is a better starting point when you want color ramps that change lightness more predictably across hues.

The same number can mean two different things

In oklch(L C H), L is Oklab lightness, C is chroma and H is the hue angle. HSL and OKLCH have different axes and hue angles; do not paste an HSL angle into OKLCH expecting the same color. Here are two comparisons against white. Each row contains its own sRGB value and measured ratio.

CSS sourcesRGB HEXContrast on white
hsl(60 100% 50%)#FFFF001.07:1
hsl(240 100% 50%)#0000FF8.59:1
oklch(65% 0.12 100)#A0902A3.22:1
oklch(65% 0.12 260)#638FD83.26:1

The OKLCH entries are in sRGB; the HEX values are their rounded 8-bit conversions. The smaller contrast gap is a result for this example, not a theorem for all hues. Even these two close ratios are insufficient for normal text on white under WCAG AA.

Bring chroma back into the intended gamut

Try doubling the blue sample’s chroma to oklch(65% 0.24 260). Converting it produces a linear sRGB blue channel of about 1.294, above the valid range of 0 to 1. This is a valid CSS color coordinate outside sRGB, not a malformed color. For this example we deliberately reduce chroma to 0.12 at the same L and H to get an in-gamut #638FD8. That is a design choice, not a claim about the browser’s exact gamut mapping. The CSS gamut-mapping discussion explains why simple clipping can change the color in unwanted ways.

An in-gamut OKLCH token with a tested sRGB fallback
/* Ink remains separate from the decorative accent. */
.note {
  color: #080C14;
  background: #F5F9FB;
  border-inline-start: 4px solid #638FD8;
  padding: 0.75rem;
}
@supports (color: oklch(65% 0.12 260)) {
  .note { border-inline-start-color: oklch(65% 0.12 260); }
}

The strip is decorative, not the only cue for the note. If you use custom properties for this pattern, put the OKLCH variable override inside the feature query. Unregistered custom properties can store a token string even when the browser cannot use it as a color; the earlier color may not be recovered after substitution. See CSS Custom Properties.

Pick semantic roles and verify them separately

For production UI, keep the neutral surfaces and ink separate from accents. The following HEX values are independent, already-in-sRGB examples for token roles; they are not claimed P3 conversions. Darken or change the role of a failing accent instead of assuming that an equal OKLCH L rescues it.

RoleForeground / backgroundContrastNormal text
Body ink on frost#080C14 / #F5F9FB18.48:1AAA
Indigo link on frost#4A1A96 / #F5F9FB10.55:1AAA
Cyan label on white#065A60 / #FFFFFF7.96:1AAA
Amber accent on obsidian#D99B26 / #080C148.08:1AAA
Amber accent on white#D99B26 / #FFFFFF2.42:1Fails AA

Check the palette on the actual backgrounds, with the actual alpha and component states. For an exact sRGB comparison, enter the resolved HEX pair in the Contrast Checker. Do not use a screenshot sample as proof of a source token’s exact value, and test the displayed wide-gamut version separately if you ship one.

Frequently asked questions

Does the same OKLCH lightness give two colors the same WCAG contrast?

No. OKLCH lightness is a perceptual coordinate, not WCAG relative luminance. Check the final foreground and background values, including their fallback values and any blending.

Does using oklch() require a Display P3 monitor?

No. OKLCH is a color notation, not a display gamut. Many OKLCH coordinates are inside sRGB. Others are outside sRGB or even outside Display P3, so test or map them for the intended output.

What is an sRGB fallback for an OKLCH token?

It is a usable sRGB color for the same token role. For an in-gamut OKLCH color it can be a close 8-bit conversion. For a wider-gamut color it is an approximation you should choose and test, not an exact encoding of an unrepresentable color.

Related reading

Continue exploring this color story

New Palette Library

Explore 120 curated color palettes

Website, SaaS, brand, minimal, dark, pastel, and seasonal palettes ready for design work.

Open Palettes