There aren’t really big gaps in OKLCH where it just doesn’t render any color at all.

I like the color picker at https://oklch.com/ — it’s well-done and handy. I use it fairly regularly, in part because most other “color pickers” don’t offer anything P3-anything, let alone the particular model varietal you might want in CSS, which is annoying. (I emailed Sip the other day, the picker I usually use, to see what they’d say about it, but I didn’t hear back.)

There is one big misconception about OKLCH that oklch.com fosters though (at least in me). It’s this:

OKLCH.com interface showing a particular color as "Unavailable on any device".

If you move around the controls and the cross-hair selector is on part of the model, you see a preview of that color. If you are off the model, it says “Unavailable on any device” — which makes it feel like that color is entirely invalid and will not render.

But if we use that color, oklch(58.61%, 0.185 71.72), assuming your browser supports OKLCH, it’s fine:

This div has background: oklch(58.61% 0.185 71.72);

Imagine if we set the Lightness at 70% and the Chroma at 0.185 and rotate the Hue from 0 to 360. You might imagine, as I did, that the color will… disappear?… I guess?… at three different gaps during that rotation.

gaps in the color model at an exact lightness and chroma, across the hue.

But check it out by sliding this range slider:

No gaps. The color never disappears. It’s totally fine.

So when you (cough: I) say something like “OKLCH is great for design systems and programmatic control of color because you can deterministically alter the color values and get expected results”, that’s no lie.

So, what’s the deal with those “Unavailable on any device” colors? Best I understand it, they are rather “out of range” for the color model, but there is built-in browser magic in place that pulls the values back into range. It picks the best I know what you meant color match. I suppose it is the same concept as when you are using a browser that supports P3 color, but a display that doesn’t. Magic happens that pulls the colors down into a reasonable, display-able place. It doesn’t just not show the color. I think there are competing and opinionated algorithms that do this, I’m not up to snuff on all that.

Even totally absurd values work:

This div has background: oklch(1000% 4 745861);

🤘

CodePen

I work on CodePen! I'd highly suggest you have a PRO account on CodePen, as it buys you private Pens, media uploads, realtime collaboration, and more.

Get CodePen PRO

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to Top ⬆️