w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.46k stars 657 forks source link

[css-color-5] Colors where all channels (except) alpha have a value of `none` #10203

Open romainmenke opened 5 months ago

romainmenke commented 5 months ago

https://github.com/w3c/csswg-drafts/issues/10151#issuecomment-2052685363

@LeaVerou said in the context of preserving none in color space conversion:

If all components in the source color (except alpha) are none, then they remain none. (oklch(none none none / 0%) is like transparent on steroids)


I like this, I think it is useful. It allows authors to get the full color of one side of an interpolation without knowing anything about that color.

Example:

.foo {
  color: color-mix(in oklab, var(--color-a), pink);
}

.bar {
  --color-a: rgb(none none none);
}

The author might not know what the other color or interpolation space is. Setting a color with all channels to none creates a reliable way to get that pink.

I can even imagine a keyword for this: opaque which has a value of rgb(none none none / 100%)

svgeesus commented 3 months ago

I can even imagine a keyword for this: opaque which has a value of rgb(none none none / 100%)

That would indeed be a nice addition to the existing transparent (which, if we were defining it today, would have been better as rgb(none none none / 0%)