diff --git a/src/content/blog/colors-in-css.mdx b/src/content/blog/colors-in-css.mdx index 6e9b08d2..d27b9f40 100644 --- a/src/content/blog/colors-in-css.mdx +++ b/src/content/blog/colors-in-css.mdx @@ -15,19 +15,19 @@ import ColorPickerOklch from "../../components/_ColorPickerOklch.jsx"; ### A little bit of history -First, there was the [CIELAB](https://en.wikipedia.org/wiki/CIELAB_color_space) ("Lab") perceptually uniform color space. Then in 2020, [Björn Ottosson created Oklab](https://bottosson.github.io/posts/oklab/) ("an OK Lab color space") to address Lab's problems when used with modern displays. But Oklab uses Cartesian coordinates which is great if you're a computer, but pretty cryptic otherwise… So OKLCH was added to the mix soon after, using polar coordinates, which makes it much easier to use (similar to HSL) for non-robots. +First, there was the [CIELAB](https://en.wikipedia.org/wiki/CIELAB_color_space) ("Lab") perceptually uniform color space. Then in 2020, [Björn Ottosson created Oklab](https://bottosson.github.io/posts/oklab/) ("an OK Lab color space") to address Lab's problems. But Oklab uses Cartesian coordinates, which are great if you're a computer, but pretty cryptic otherwise… So OKLCH was added to the mix, using polar coordinates, which makes it much easier to use (similar to HSL) for non-robots. ### OKLCH syntax ```css .elem { - background-color: oklch(0.59 0.13 242); /* blue */ + background-color: oklch(0.59 0.13 242); /* blue */ } ``` - **L**ightness controls how light or dark the color is. From `0` – `1` (or `0%` – `100%`). -- **C**hroma is similar to saturation, but [different](https://en.wikipedia.org/wiki/Munsell_color_system#Chroma): it's how a color _looks_ compared to a neutral gray of the same brightness. A "safe" range is `0` – `0.35`, Values above ~`0.37` will be clipped on most monitors. -- **H**ue controls what part of the color wheel to sample. From `0deg` – `360deg` +- **C**hroma is similar to saturation, but [different](https://en.wikipedia.org/wiki/Munsell_color_system#Chroma): it's how a color _looks_ compared to a neutral gray of the same lightness. A "safe" range is roughly `0` – `0.32` for sRGB and `0.36` for P3, and often less on most monitors. +- **H**ue controls what part of the color wheel to sample. From `0deg` – `360deg`. ### Why use OKLCH @@ -64,7 +64,7 @@ You can create design system palettes using the same hue while tweaking lightnes ### Accessibility -This "perceptually uniform" business makes it the best option for a11y friendly palettes. Here's a comparison between HSL and OKLCH that makes it clear why. We're only changing the **Hue** angle by the same amount in both. (Switch to dark mode to make it even more evident.) +This "perceptually uniform" business makes it the best option for a11y-friendly palettes. Here's a comparison between HSL and OKLCH that makes it clear why. We're changing the **Hue** angle by the same amount in both and keeping the **Lightness** the same. (Switch to dark mode to make it even more evident.) {/* prettier-ignore */}