← Back to list

Why you should use OKLCH in CSS

As the modern web design landscape evolves, so do our tools for creating rich, consistent visual experiences.

Sean Amarasinghe · 2025-11-05 05:24 · 2 claps · 4.3 min read paywalled
#css #oklch #web-development #web-design #front-end-development
Open on Medium ↗
Wiki topics: DSN · Design · General 🌐 · Web Development

Why you should use OKLCH in CSS

As the modern web design landscape evolves, so do our tools for creating rich, consistent visual experiences.

One of the most exciting updates to modern CSS color management is OKLCH, introduced around 2021 as part of the CSS Color 4 specification.

But what is OKLCH, and why does it matter?

What Is OKLCH?

OKLCH is a color model designed to represent colors the way humans actually perceive them.

Proposed by Björn Ottosson in 2020, OKLCH was built to be perceptually uniform — meaning that when you tweak a color’s parameters, it changes in a way that feels consistent to the human eye.

If you’ve ever adjusted a color in RGB or HSL and ended up with strange, uneven results, you’ve experienced the opposite of perceptual uniformity. OKLCH fixes that.

The OKLCH 3D color model visualized at oklch.com

The OKLCH 3D color model visualized at oklch.com

Unlike RGB, which represents colors as combinations of red, green, and blue light, OKLCH breaks color down into three intuitive parts:

  • LLightness (0 → 1 or 0% → 100%)
  • CChroma, or color intensity (0 → 0.37 for most gamuts)
  • HHue, the actual color, expressed in degrees (0°–360°)
  • AOpacity (optional, 0–1 or 0–100%)

Here’s how that looks in CSS:

.box {
  background: oklch(0 0 0);      /* black */
  color: oklch(1 0 0);           /* white */
  color: oklch(50% 0.30 10);     /* red */
  color: oklch(50% 0.30 0);      /* pink */
}

.opacity {
  color: oklch(50% 0.37 20 / 50%); /* transparent red */
}

[embed]

Because OKLCH is designed around human perception, it produces smoother gradients, predictable adjustments, and better consistency across devices — especially on modern displays using Display P3, which offers about 50% more colors than the older sRGB gamut.

sRGB vs Display P3 color gamut from WebKit

sRGB vs Display P3 color gamut from WebKit

Why OKLCH Is a Game-Changer

1. Perceptual Uniformity

OKLCH’s greatest strength is that equal numeric changes mean equal visual changes.

Let’s say you want lighter and darker versions of a base color.

In OKLCH, you simply adjust the Lightness (L) value:

.dark {
  background-color: oklch(0.4 0.2 10);
}

.base {
  background-color: oklch(0.6 0.2 10);
}

.light {
  background-color: oklch(0.8 0.2 10)
}

[embed]

Because OKLCH is perceptually uniform, these shades look evenly spaced — no weird hue shifts or unexpected dulling.

Try the same in RGB or HSL, and you’ll often get uneven or muddy results.

Equal lightness adjustments result in perceptually even tones.

2. Better Control of Brightness and Contrast

Brightness and contrast adjustments behave as you’d expect.

Lowering L makes the color darker without shifting its hue or intensity.

Increasing C boosts vibrancy without changing perceived brightness.

/* Base */
.base {
  background-color: oklch(0.7 0.15 0);
}

/* Dark */
.dark {
  background-color: oklch(0.5 0.15 0);
}

/* High-contrast */
.high-contrast {
  background-color: oklch(0.7 0.3 0);
}

[embed]

This level of precision is a dream for accessibility and UI consistency — especially when ensuring sufficient color contrast for text and icons.

3. Wide Gamut Support

OKLCH supports sRGB, Display P3, and even Rec.2020, letting you tap into a much broader range of colors on modern screens.

That means more vivid gradients, richer tones, and fewer “flat” colors that look lifeless on high-end displays.

4. Smoother Gradients

Traditional color spaces like HSL can produce harsh or dull transitions in gradients — especially when moving between very different hues.

For example, an HSL gradient from blue to yellow often includes a dull grey in the middle:

.gradient-hsl {
  background-image: linear-gradient(to right,
    hsl(220deg 100% 50%),
    hsl(50deg 100% 50%));
}

Notice the grey area in the middle caused by non-uniform color transitions.

Switch that to OKLCH, and you’ll get buttery-smooth transitions without losing saturation mid-way:

.gradient-oklch {
  background-image: linear-gradient(to right,
    oklch(44% 0.31 264),
    oklch(94% 0.21 109));
}

Smooth, perceptually even color transition in OKLCH.

[embed]

5. Solid Browser Support

OKLCH is now supported by all major browsers.

For older versions, you can use fallbacks or polyfills to ensure graceful degradation.

Check up-to-date support on Can I Use.

Browser support for OKLCH across major platforms.

Why you should OKLCH?

There are many reason why you should be adapting OKLCH.

Accessibility First

OKLCH’s perceptual uniformity helps us fine-tune contrast and readability, ensuring our UI meets accessibility (A11y) standards out of the box.

Even when users customize their color themes, OKLCH helps maintain accessible contrast ratios and predictable tone relationships.

Embracing Wide Gamuts

Our File Uploader appears across products — from web apps to CMS plugins.

OKLCH lets our interface shine equally well on high-end Retina displays and standard monitors.

Future-Proofing with Relative Colors

CSS relative color syntax is the future — it lets developers create new colors by adjusting lightness, chroma, or hue from existing ones.

OKLCH pairs perfectly with this approach, making design systems easier to scale and maintain once browsers fully support relative color adjustments.

Wrapping Up

OKLCH represents a major leap in web color management, bridging the gap between mathematical accuracy and human perception.

It also helps you build a more accessible, visually consistent File Uploader that looks great everywhere.

For designers and developers alike, OKLCH isn’t just another color format — it’s a new foundation for how we craft color on the modern web.


메타데이터
post_id
4dd7542f6da4
slug
why-you-should-use-oklch-in-css-4dd7542f6da4
url
https://medium.com/@szaranger/why-you-should-use-oklch-in-css-4dd7542f6da4
canonical_url
https://medium.com/@szaranger/why-you-should-use-oklch-in-css-4dd7542f6da4
author_url
https://medium.com/@szaranger
status
ok
fetched_at
2026-06-27 07:40:21