2025-08-25 02:32:00
jakub.kr
OKLCH is a newer color model that is designed to be perceptually uniform. This means that colors are much more accurate in terms of how humans perceive them and it makes working with them much easier.
Color Models
Before being able to understand how OKLCH differs from the other color models, it is important to understand some of the basic color concepts.
Color models are systems to describe colors. These include RGB, HSL, LCH, OKLCH and more. The model determines how easy it is to manipulate or think about a color.
oklch(0.55 0.18 260)
hsl(220 100% 50%)
rgb(0, 128, 255)
lch(60% 60 260)
lab(50 -10 -50)
color(xyz 0.18 0.19 0.6)
#1E90FF
Gamut
Gamut is a playing field where the model lives and defines what colors are possible. Common gamuts include sRGB (the web default) and Display-P3 (used on modern devices).
There is a lot more nuance when you get into color spaces. They don’t just define a gamut, but also things like the white point and transfer function. I decided to leave those out for the sake of keeping the article simple.
Structure
OKLCH, same as LCH, consists of three values: Lightness, Chroma and Hue. The difference between the two is the underlying color space that the color model uses, which in case of OKLCH, is OKLab.
Lightness – Equal steps feel like equal changes in brightness. Ranges from value between 0 and 1 or percentage ranging from 0% to 100%.
Chroma – Controls intensity of the color, similar to saturation.
Hue – Controls the hue, measured in degrees ranging from 0 to 360.
Consistent Brightness
Let’s say you want to create a couple of pill buttons and you want each one to have a different color. The usual workflow with sRGB colors would be defining the first color and then handpicking others to match it.
With OKLCH, you can use the same value for all of them and only change hue. That way you create colors that look and feel the same.
oklch(0.7 0.16 30)oklch(0.7 0.16 150)oklch(0.7 0.16 250)oklch(0.7 0.16 320)
hsl(30 100% 50%)hsl(150 100% 50%)hsl(250 100% 50%)hsl(320 100% 50%)
You can do the same thing with color models like HSL, but as you can see above, the colors don’t look uniform. Some are lighter, some darker, some pop more and some less.
This is one of the major advantages of OKLCH over other color models. Creating perceptually uniform color palettes and working with them is very easy.
Predictable Shades
It also works the other way around, where you can change the lightness value to create various color shades and there is no hue or saturation drift unlike in other color modes.
In the example above, you can see that the OKLCH colors maintain consistent blueness across all of the shades, while in the HSL example, the lighter shades drift to purple and the darker ones muddy out towards grayish.
Better Gradients
The way gradients work in OKLCH is pretty different compared to sRGB. In sRGB, gradients are calculated in red, green, and blue values, which often leads to muddy midpoints and uneven brightness.
With OKLCH, the math follows lightness, chroma, and hue. In the example above you can see that the starting and ending points are the same but the colors the gradient passes through are quite different.
Color Space Support
sRGB can’t reach a lot of colors that modern screens can show. In OKLCH you can write colors that are only possible to render on a screen that supports Display-P3 colors.
If you are on a display that supports Display-P3, you will see the right color much more vivid than the left one. If you are on a display that only supports sRGB, the color should look identical, as the browser maps the out of gamut color back inside the sRGB gamut.
Keep in mind that grays are identical in sRGB and Display-P3, so there would be no difference there.
Maximum Chroma
OKLCH can also define more colors than any real screen can show. It can specify values that don’t fit inside any actual gamut like sRGB or Display-P3.
Let’s take this color as an example color: oklch(0.7 0.4 40)
. It has a very high chroma value and it could mathematically exist but in practice it lies outside of any real display’s gamut. When this color is used, it will get clipped or mapped to the nearest representable color inside the gamut.
@layer base {
:root {
color: oklch(0.7 0.4 40);
}
}
Generally you don’t want this to happen, as the clipped color can often look very different from the defined one.
Therefore, there is a concept of a maximum chroma value, which calculates the maximum chroma that a display can show based on the lightness, hue and the selected gamut like sRGB or Display-P3.
Browser Support & Fallbacks
OKLCH colors were introduced in CSS Color Module Level 4 and they are well supported across all modern browsers.
However, there are still some surfaces where OKLCH colors are not supported such as outdated browsers. In case you are worried about this, you can add fallbacks and use the @supports
directive in CSS.
@layer base {
:root {
/* sRGB hex */
--color-gray-100: #fcfcfc;
--color-gray-200: #fafafa;
--color-gray-300: #f4f4f4;
@supports (color: oklch(0 0 0)) {
/* OKLCH */
--color-gray-100: oklch(0.991 0 0);
--color-gray-200: oklch(0.982 0 0);
--color-gray-300: oklch(0.955 0 0);
}
}
}
This way the browser uses OKLCH colors if they are supported, otherwise it falls back to sRGB.
oklch.fyi
I built a small tool dedicated to OKLCH colors called oklch.fyi. It helps generate OKLCH colors palettes, it can take your existing CSS variables and convert them to OKLCH and more.
More
In case you have any questions reach me at jakub@kbo.sk or see more of my work on Twitter.
Keep your files stored safely and securely with the SanDisk 2TB Extreme Portable SSD. With over 69,505 ratings and an impressive 4.6 out of 5 stars, this product has been purchased over 8K+ times in the past month. At only $129.99, this Amazon’s Choice product is a must-have for secure file storage.
Help keep private content private with the included password protection featuring 256-bit AES hardware encryption. Order now for just $129.99 on Amazon!
Help Power Techcratic’s Future – Scan To Support
If Techcratic’s content and insights have helped you, consider giving back by supporting the platform with crypto. Every contribution makes a difference, whether it’s for high-quality content, server maintenance, or future updates. Techcratic is constantly evolving, and your support helps drive that progress.
As a solo operator who wears all the hats, creating content, managing the tech, and running the site, your support allows me to stay focused on delivering valuable resources. Your support keeps everything running smoothly and enables me to continue creating the content you love. I’m deeply grateful for your support, it truly means the world to me! Thank you!
BITCOIN bc1qlszw7elx2qahjwvaryh0tkgg8y68enw30gpvge Scan the QR code with your crypto wallet app |
DOGECOIN D64GwvvYQxFXYyan3oQCrmWfidf6T3JpBA Scan the QR code with your crypto wallet app |
ETHEREUM 0xe9BC980DF3d985730dA827996B43E4A62CCBAA7a Scan the QR code with your crypto wallet app |
Please read the Privacy and Security Disclaimer on how Techcratic handles your support.
Disclaimer: As an Amazon Associate, Techcratic may earn from qualifying purchases.