opyeb ColorOKLCH

15 guides · Gamut

Gamut mapping — clipping and chroma reduction are not the same

Basis 28 November 2026 · Gamut · about 7 min

A colour outside the gamut cannot be shown as it is. Browsers and tools replace it with the closest displayable colour, and that process is gamut mapping. The problem is that “closest” has several definitions: clipping each RGB channel, reducing chroma, or compressing the whole palette. Each produces a different result.

Four methods

MethodWhat it doesSide effect
Channel clippingclamps channels outside 0–1 to 0 or 1shifts hue and crushes neighbouring shades together
Chroma reductionkeeps L and H, lowers C until it fitsmost predictable; only saturation drops
Perceptual compressionscales the whole palette into the gamutevery colour moves, palette balance survives
Relative colourbrowser maps to the display gamutslightly different per browser

Channel clipping is the fastest and the worst. When the blue channel clamps at 1, lightness and hue both shift, and two adjacent colours can collapse into one. CSS gamut mapping is not simple clipping for exactly this reason.

The calculator reduces chroma

For every step outside the gamut the calculator keeps L and H and binary-searches C between zero and the requested value. Twenty-eight iterations put the error around 1e-9, which is exact enough. The advantage is predictability: it can report how much chroma was clipped, and other steps of the same hue stay aligned.

lo = 0, hi = C
repeat 28 times:
  mid = (lo + hi) ÷ 2
  if mid is inside sRGB: lo = mid, else hi = mid
result C = lo

The resulting hex is an approximation. On a P3 display the original oklch() value survives, so the code carries both the hex and the oklch() value, separated by @supports. That is exactly what the export produces.

When clipping is defensible

Chroma reduction is not always the answer. In photographs and gradients, where colour changes continuously, clipping can look more natural. In UI tokens, where colours are discrete and their relationships matter, chroma reduction is better. The test is whether the relationship between colours carries meaning.

A short checklist

Mapping behaviour follows the CSS Color 4 gamut mapping section and Ottosson's OKLab discussion.

Questions

How does a browser handle an out-of-gamut oklch()?

It maps the colour to the display gamut. Current browsers consider perceptual distance rather than simple clipping, but implementations differ slightly.

Should I lower chroma or lightness first?

For UI palettes, chroma. Changing lightness also disturbs contrast and the step relationships.

Is there a case for deliberately out-of-gamut colour?

Yes: accents and decoration that should look vivid on P3 screens. Always define the hex fallback with it.

Raise chroma and see which step clips first in the palette tab.

Open the tool

Basis date 28 November 2026. Written against the W3C specifications, the APCA documentation and published browser support tables; updated when they change.

Back to the guides