I've finally managed to get relative CSS colors documentation published on MDN. This was a complex beast to tackle, and I'm proud to see it out! Get started at https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_colors/Relative_colors; also see the color function pages to find out what relative colors look like in each.
Using relative colors - CSS | MDN

The CSS colors module defines relative color syntax, which allows a CSS <color> value to be defined relative to another color. This is a powerful feature that enables easy creation of complements to existing colors — such as lighter, darker, saturated, semi-transparent, or inverted variants — enabling more effective color palette creation.

MDN Web Docs

@chrisdavidmills awesome!

I'm a little confused, as it seemed like all the colours added after the 'from' were named colours. But it could be anything, right?

One of my biggest annoyances is always being issued colours in hex format - so it'd be great to see an example where hsl() takes some hex value like #ff0080 and spits out the same colour albeit with maybe a change in luminance or something.

But also, TIL. This fixes exactly my annoyance, it would be cool to not always convert colours!

@sarajw That's correct — the origin color can be hex, named colors, any function, a CSS variable, even another relative color.

I do say that early on in the guide, but perhaps I should have varied the examples a bit more. I wanted to keep the early examples really simple to avoid making readers think of too many things at the same time when getting used to the syntax.

BUT, having colors delivered via hex codes is still super common, as your message attests. Could do with some examples?

@chrisdavidmills It's a great guide, I've definitely learned something!

But yes maybe if there's a section that does nothing but switch different formats in and out, rgb to hsl, hex to rgb, rgb to olch, or what have you.

Otherwise I find I'm forever visiting https://convertacolor.com - it's a cool site but it's a step I'll be happy to avoid from now on!

Convert a Color – HEX, RGB, HSL, CMYK

Convert colors between formats HEX, RGB, HSL and CMYK. Simple, beautiful and fast.

@chrisdavidmills Sorry reread your message - concrete example:

I get a hex value out of some random color picker: #8EAAA5

I'd like to use this colour, and get some darker versions of it as well.

So (hopefully I've got this right), I could do it like this:

```
--theme: hsl(from #8EAAA5 h s l);
--darker: hsl(from #8EAAA5 h s 50%); // #6E918B
--darkest: hsl(from #8EAAA5 h s 35%); // #4D6661
```

@sarajw Great, thanks for the example! I'll look into adding something next week.
@chrisdavidmills Hey! Do you mind if I reference relative colors and your article in a talk?

@sarajw Hey! that is totally cool with me.

I've not forgotten about the hex colors examples either; just snowed under with other stuff currently.

@chrisdavidmills no worries!

@chrisdavidmills I'm afraid at the last minute it's going to come out of my talk because I think I may have found a bug!

Seems like doing say `hsl(from Canvas 30 s l);` doesn't follow how Canvas (a system color) flips between near-white to near-black when `color-scheme` changes from light to dark.

Interesting though!

#CSS #IsItABug #OrIsItJustMe

@sarajw oh, interesting; that sounds like a super fun bug. I'm assuming you've reported it to the Chrome folks; be interesting to see what they say.

I've still got the changes we discuss on my radar; been so busy that I've not had time. I'm currently in the middle of documenting CSS anchor Positioning; possibly after that.

@chrisdavidmills Oh don't feel bad about that! Yes I need to work out where to put that issue and how to search that it's not already there...

@chrisdavidmills Bramus helped me out :)

Just changed the example I wrote two replies up as of course the lightness won't change when I set the lightness - but still having that trouble anyway.