What is OKLCH? The Complete Guide to Perceptually Uniform CSS Colors
Learn why OKLCH is replacing HSL and HEX in modern CSS. Understand Lightness, Chroma, and Hue with practical examples, browser support, and tool recommendations.
Key Technical Takeaway
OKLCH is a perceptually uniform color space derived from the Oklab color model. It solves fundamental flaws in HSL by ensuring equal perceived lightness across all hues.
What is OKLCH?
If you have been writing CSS for more than a few years, you are probably comfortable with HEX codes and maybe HSL. They work. They are supported everywhere. And for a long time, they were good enough.
But here is the problem: HSL lies to you.
Not intentionally, of course. But when you set two colors to the same "lightness" value in HSL, they do not actually look equally bright to the human eye. A yellow at hsl(60 100% 50%) and a blue at hsl(240 100% 50%) have identical lightness numbers, yet the yellow appears dramatically brighter. This is not a bug in your monitor. It is a fundamental flaw in how HSL models color.
That is where OKLCH comes in.
OKLCH is a perceptually uniform color space that is quickly becoming the default choice for serious web designers and developers. It is part of the CSS Color Module Level 4 specification, supported in all modern browsers, and it solves problems that HEX and HSL simply cannot.
In this guide, we will break down exactly what OKLCH is, how it works, why it matters for your projects, and how to start using it today.
Why OKLCH Matters for Modern Web Design
Let us start with a simple experiment. Open your dev tools and create two CSS rules:
`.box-yellow { background: hsl(60 100% 50%); }` `.box-blue { background: hsl(240 100% 50%); }`
Place them side by side. Which one looks brighter?
The yellow almost certainly jumps out at you. It feels luminous, energetic, almost aggressive. The blue, meanwhile, feels darker, more subdued, even though both are sitting at exactly 50% lightness.
This happens because HSL is based on the RGB color cube, which does not account for how human eyes actually perceive brightness. Our eyes are far more sensitive to green and yellow light than to blue. HSL ignores this biological reality.
OKLCH does not. It is built on the Oklab color space, which was specifically designed to match human vision. In OKLCH, 50% lightness means 50% perceived brightness, regardless of hue. A yellow at 50% lightness and a blue at 50% lightness will actually look equally bright.
- Predictable gradients: A gradient from blue to yellow in OKLCH stays consistently bright. In HSL, it often turns muddy gray in the middle.
- Accessible palettes: When you darken a color for hover states, OKLCH ensures the perceptual drop is consistent across your entire palette.
- Design system scales: Generating a 50-950 shade scale from a brand color is far more reliable in OKLCH because each step is visually uniform.
Understanding OKLCH: Lightness, Chroma, and Hue
OKLCH uses three coordinates, just like HSL. But the similarity ends there.
- L — Lightness (0% to 100%): Lightness in OKLCH is perceptual. 0% is always black. 100% is always white. And 50% is always middle gray, regardless of hue or chroma. When you adjust the lightness of a brand color to create hover states, you can trust that a 10% drop in OKLCH will look like a 10% drop, whether you are working with orange, purple, or teal.
- C — Chroma (0 to approximately 0.4): Chroma represents color intensity or saturation. A chroma of 0 is completely grayscale. Higher values are more vivid and saturated. Chroma has a maximum that depends on hue and lightness. HSL lets you set 100% saturation for any color, but the result often falls outside what a screen can display. OKLCH respects physical boundaries.
- H — Hue (0° to 360°): Hue works similarly to HSL: 0° is red, 120° is green, 240° is blue, and so on around the color wheel. Rotating hue in OKLCH does not accidentally change the perceived brightness.
The CSS Syntax
Using OKLCH in CSS is straightforward:
.brand-color {
background: oklch(70% 0.2 250);
}
/* 70% = lightness, 0.2 = chroma, 250 = hue angle (roughly blue) */
.brand-color-faded {
background: oklch(70% 0.2 250 / 0.5);
}OKLCH vs HSL: A Side-by-Side Comparison
Let us look at a practical example. You want to create a gradient from blue to yellow for a hero section.
/* In HSL: */
.gradient-hsl {
background: linear-gradient(to right, hsl(240 100% 50%), hsl(60 100% 50%));
}
/* In OKLCH: */
.gradient-oklch {
background: linear-gradient(to right, oklch(50% 0.3 250), oklch(90% 0.3 100));
}- Button hover states: Darkening a color in OKLCH produces predictable results.
- Dark mode adaptation: Shifting lightness values in OKLCH maintains readability without guesswork.
- Color mixing: Blending two colors in OKLCH (using CSS color-mix()) produces natural intermediates instead of muddy averages.
How to Convert Your Existing Colors to OKLCH
You do not need to throw away your existing color palette. Converting HEX or RGB values to OKLCH is a simple calculation, and tools make it instant.
The conversion path looks like this: HEX → sRGB → Linear sRGB → XYZ → Oklab → OKLCH
That is a lot of math, but you never need to do it by hand. You can use PaletteKey’s Color Converter to convert any HEX, RGB, or HSL value to OKLCH instantly. Just paste your color, and the tool outputs the OKLCH equivalent along with every other format.
For example: • HEX #3B82F6 (Tailwind blue-500) • Converts to: oklch(62.3% 0.19 259.8)
Once you have the OKLCH value, you can start manipulating it directly in CSS or in your design system.
OKLCH for Design Systems and Component Libraries
If you maintain a design system, OKLCH is transformative.
**Generating Shade Scales** Design systems typically need 9-11 shades of each brand color, from near-white (50) to near-black (950). In HSL, generating these shades is guesswork. You might decrease lightness by 10% each step, but the visual result is inconsistent.
In OKLCH, you can decrease lightness by exactly the same perceptual amount each step. The result is a smooth, visually uniform scale that works across every hue in your palette.
PaletteKey’s Tailwind Color Generator builds these scales automatically. Enter any brand color, and it generates the full 50-950 scale in OKLCH format, ready to export as a Tailwind config.
**Consistent Hover and Active States** When a user hovers over a button, you typically darken it slightly. In OKLCH, the same lightness adjustment produces a visually consistent effect across your entire component library.
**Dark Mode Without Guesswork** Adapting a light-mode palette to dark mode is simplified because you can reason about lightness independently from hue and chroma. A color at 70% lightness will always be a light color, whether the background is white or dark gray.
Browser Support: Is OKLCH Safe to Use?
Yes. As of 2024, OKLCH is supported in Chrome 111+, Safari 16.2+, Firefox 113+, and Edge 111+. That covers well over 90% of global browser usage. For older browsers, you can provide a simple HEX or RGB fallback:
.brand-color {
background: #3B82F6; /* Fallback for old browsers */
background: oklch(62.3% 0.19 259.8); /* Modern browsers */
}Start Using OKLCH Today
You do not need to rebuild your entire design system overnight. Start small: 1. Convert your brand colors to OKLCH. 2. Use OKLCH for your next gradient or hover state. 3. Notice how much more predictable the results feel. 4. Gradually expand OKLCH usage across your project.
The shift from HSL to OKLCH is not just a syntax change. It is a shift from working with a mathematical abstraction to working with how humans actually see color. Once you make that shift, you will not want to go back.
Ready to explore OKLCH? Try PaletteKey’s OKLCH Color Picker to find your next color with precise Lightness, Chroma, and Hue controls.
Frequently Asked Questions
What does OKLCH stand for?
OKLCH stands for Oklab Lightness, Chroma, Hue. It is a cylindrical color space derived from the Oklab perceptually uniform color model, created by Björn Ottosson in 2020.
Is OKLCH better than HSL for web design?
Yes. OKLCH is perceptually uniform, meaning that 50% lightness looks equally bright regardless of hue. HSL is not perceptually uniform — yellow at 50% lightness appears much brighter than blue at 50% lightness. This makes OKLCH more predictable for gradients, hover states, and accessible design.
Which browsers support OKLCH?
As of 2024, OKLCH is supported in Chrome 111+, Safari 16.2+, Firefox 113+, and Edge 111+. This covers over 90% of global browser usage. For older browsers, provide a HEX or RGB fallback.
What is Chroma in OKLCH?
Chroma (C) represents color intensity or saturation. A chroma of 0 is grayscale. Higher values are more vivid. Unlike HSL saturation, chroma has a maximum that varies by hue and lightness, which reflects real perceptual and physical limits.
How do I convert HEX to OKLCH?
Use a color converter tool like PaletteKey's Color Converter. Enter any HEX, RGB, or HSL value, and it outputs the OKLCH equivalent instantly using standard CIE color science transformations.
Can I use OKLCH with Tailwind CSS?
Yes. Tailwind v4 natively supports OKLCH in its CSS-first configuration. For Tailwind v3, you can generate OKLCH-based scales and convert the final values to HEX for the config file.
What is the maximum Chroma value in OKLCH?
The maximum chroma depends on the hue and lightness. At 50% lightness, most hues max out around 0.37. At very light or very dark values, the maximum is lower. PaletteKey's OKLCH Color Picker visualizes this boundary.
Is OKLCH part of official CSS?
Yes. OKLCH is part of the CSS Color Module Level 4 specification, which is a W3C Candidate Recommendation. It is not experimental and will not be deprecated.
Why do OKLCH gradients look better than HSL gradients?
OKLCH gradients interpolate in perceptual space, so the middle colors maintain consistent brightness and hue integrity. HSL gradients interpolate through the RGB cube, which often creates muddy gray intermediates between colors like blue and yellow.
Should I replace all my HSL colors with OKLCH?
Not overnight. Start by converting your brand colors to OKLCH, then use OKLCH for new components, gradients, and design system scales. Over time, expand OKLCH usage across your entire project.