Here is an example. That's a hue lightness slice of HSL and for conversion KLCH color space with the same chroma and black and white versions below. As you can see, HSL lightness is not consistent across hue axes. Different hues represent different real lightness values. This leads to issues with contrast and bad accessibility. But KLCH lightness, on the other hand, is consistent and ensures accessibility. That's why KLCH is our choice for dynamic themes.
Let me say a few words about it. KLCH is a relatively new color space designed for perceptual uniformity and it's perfect for creating dynamic themes, as color modifications are extremely simple with it. Despite it's quite new, it can be used in all modern browsers. Here is a more detailed explanation of each KLCH axe. L lightness is perceived lightness. It ranges from 0, which is black, to 1, which is white, or from 0% to 100%. C is chroma, the saturation of color. It goes from 0, which is gray, to infinity. In practice, there is an actual limit, but it depends on the screen's color gamut. H is hue, hue angle. It goes from 0 to 360, red, which is 20, yellow, which is 90, green, 140, blue, 220, purple, 320, and then back to red. And A is alpha, is opacity. It goes from 0 to 1, or from 0% to 100%.
Here are a few examples of KLCH colors. Bright ones, black, white, gray. With KLCH, you can tweak hue, lightness, or chroma and be confident that the result will stay balanced, accessible, and visually coherent. And compare it to hex. The values look like the magic constants. We hardly can understand that the second value is just a brighter shade of blue. Unlike RGB or hex, KLCH is human readable. You can quickly understand which color and KLCH value represent simply by looking by these numbers. Now, let's talk about accessibility. HSL is bad for color modification.
Comments