Re: [csswg-drafts] [css-color-5] `light-dark()` should resolve at used value time, not computed value time (#13836)

The CSS Working Group just discussed ``[css-color-5] `light-dark()` should resolve at used value time, not computed value time``.

<details><summary>The full IRC log of that discussion</summary>
&lt;astearns> zakim, open queue<br>
&lt;Zakim> ok, astearns, the speaker queue is open<br>
&lt;TabAtkins> lea: we ahve a resolution that system colors compute to their actual value, not themselves<br>
&lt;TabAtkins> lea: motivated by an emilio example about authors using system colors and them inheriting into descendants<br>
&lt;TabAtkins> lea: but, people define colors in css varaibles today<br>
&lt;TabAtkins> lea: the mental model people mostly have is that light-dark() is dynamic and adapts to the color scheme used<br>
&lt;TabAtkins> lea: instead what we do, because light-dark() computes to one of its arguments based on the element it's used on<br>
&lt;TabAtkins> lea: so if you define colors on root, it'll base on the root element's scheme<br>
&lt;TabAtkins> lea: you could say, don't register the property as a &lt;color>, but there's good reason to do so<br>
&lt;TabAtkins> lea: there's also othe rproperties, color and accent-color<br>
&lt;TabAtkins> lea: common to set that on an ancestor and just let it filter thru<br>
&lt;TabAtkins> lea: but if you set accent-color on a parent then change color-scheme on a descendant, those dont' change<br>
&lt;TabAtkins> q+<br>
&lt;astearns> ack futhark<br>
&lt;TabAtkins> lea: that seems to be a bigger footgun than what motivated the resolution<br>
&lt;TabAtkins> lea: authors do not frequently change background along with color-scheme, that was the worry<br>
&lt;TabAtkins> lea: but having colors resolve at the point it's used seems like saying a semi-transparent color shoudl composite where it's used<br>
&lt;TabAtkins> lea: so, is the original resolution a desirable change? best for authors? and what's the impl complexities about making them resolve at used time? is it web compatible?<br>
&lt;TabAtkins> lea: right now it looks like it *might* be possible, but is tricky<br>
&lt;kbabbitt> q+<br>
&lt;TabAtkins> lea: currently used on (missed) % of pages<br>
&lt;TabAtkins> lea: so there are footguns. but i think current bheavior's footguns are easier to run into<br>
&lt;kizu> q+<br>
&lt;JoshT> s/(missed)/1.23%/<br>
&lt;TabAtkins> lea: oh, and authors have the messaging right now that registering your property type makes it animatable/etc which is good.<br>
&lt;fantasai> +1 to lea's concerns<br>
&lt;astearns> ack TabAtkins<br>
&lt;lea> TabAtkins: debated this but I think we resolved correctly<br>
&lt;lea> q+<br>
&lt;lea> TabAtkins: if we allow system colors to change as they inherit based on the current color scheme, non inherited colors will not change with it. If you correctly set a color pair and one of them is a system color, one of them will change on a descendant, the other one will not<br>
&lt;lea> TabAtkins: that is a very easy way to make your text unreadable<br>
&lt;lea> TabAtkins: suddenly become unreadable even though you didn't change any of them, you changed a third property<br>
&lt;emilio> +1<br>
&lt;lea> TabAtkins: with the current behavior even though your colors don't match the current color scheme, at least they will both be readable<br>
&lt;emilio> q+ to say that I don't understand why this is different from any other computed value change like em -> px, I think the current behavior seems reasonable<br>
&lt;lea> TabAtkins: always some possibility of confusion here but the big problem, the very easy to hit problem wasn't the text color changing but the background color not changing and that happening automatically<br>
&lt;lea> TabAtkins: and light-dark() needs to be the same because [missed]<br>
&lt;lea> TabAtkins: not a big problem because changing color-scheme is rarely done on individual elements<br>
&lt;lea> TabAtkins: aside from examples e.g. design system documentation<br>
&lt;miriam> q+<br>
&lt;astearns> s/same because [missed]/same as system color because they are connected/<br>
&lt;lea> TabAtkins: I don't see a reason to ever change the color scheme of individual elements, so I don't think this is something people will actually run into<br>
&lt;lea> TabAtkins: and that will be immediately visible, you'll spot it<br>
&lt;JoshT> At the BBC, we have use cases for changing the colour scheme on an individual element<br>
&lt;lea> TabAtkins: so I think we should stick to the current resolution<br>
&lt;astearns> ack kbabbitt<br>
&lt;TabAtkins> kbabbitt: another thing is that light-dark() can be composed with color-mix()/etc<br>
&lt;TabAtkins> kbabbitt: currentcolor usage requires maintaining a tree of unresolved colors<br>
&lt;TabAtkins> kbabbitt: concerned it's annoying/confused to have that happen more often<br>
&lt;TabAtkins> kbabbitt: i want to keep them all consistent if possible<br>
&lt;astearns> ack kizu<br>
&lt;TabAtkins> kizu: i commented today - i think i agree the current behavior is more accepted, at least for me<br>
&lt;TabAtkins> kizu: i'm quite afraid of global regressiosn if we do change it<br>
&lt;TabAtkins> kizu: another possible break if we flip it is that container-style queries that check the value of a system color will break if we change it<br>
&lt;JoshT> q+<br>
&lt;kbabbitt> to clarify, my point was about timing of resolution - I'd want to keep light-dark, color-mix, rcs all consistent about the time they resolve<br>
&lt;emilio> Yeah, to add to what kbabbitt said, all colors generally resolve to "currentColor or an absolute color" at computed value time, and `getComputedStyle` resolves `currentColor` on top... Would `getComputedStyle` start returning `light-dark()` or...<br>
&lt;TabAtkins> kizu: i also wonder if it makes sense to have an option for this<br>
&lt;emilio> +1 kbabbitt<br>
&lt;astearns> ack lea<br>
&lt;TabAtkins> kizu: so your custom property doesn't evaluate, it just checks its syntax but otherwise stays unresolved until usage, like an unregisterd dproperty<br>
&lt;fantasai> emilio, no it would continue to return the resolved color<br>
&lt;TabAtkins> lea: would push back on TAb's claim where it can't result in unreadable, i posted some examples of that.<br>
&lt;JoshT> +1<br>
&lt;emilio> But `computedStyleMap` would start returning the `light-dark(..)` tree<br>
&lt;TabAtkins> lea: that was my concern, it seemed the problem was theoretical<br>
&lt;emilio> fantasai: ^ (sorry, irc-only today)<br>
&lt;TabAtkins> lea: in practice when they set color-scheme, they don't set it on a transparent bg element, they set it on a "panel" with a bg color<br>
&lt;TabAtkins> lea: [missed an example about an element that's alway sthe opposite of the page scheme]<br>
&lt;TabAtkins> lea: we don't need to change the system color resolution, they're defined in light-dark() so they'll change to match<br>
&lt;TabAtkins> lea: but accent-color...<br>
&lt;TabAtkins> lea: system colors are basically the built-in design tokens<br>
&lt;emilio> lea, but system colors behave like light-dark() right?<br>
&lt;TabAtkins> lea: also if color-scheme shouldn't be use don elements, we maybe shouldn't have the property, weird to have it a sosmething people shouldn't use<br>
&lt;TabAtkins> lea: but there are also valid use-cases where we want it be on individual elements<br>
&lt;fantasai> emilio, yes, ideally the system colors are defined in terms of light-dark() ...<br>
&lt;TabAtkins> lea: to kevin, we alreayd have this inconsistency with currentcolor<br>
&lt;emilio> forcing a popup / etc to use `color-scheme: &lt;something different>` seems pretty reasonable<br>
&lt;lea> qq+<br>
&lt;TabAtkins> TabAtkins: Note: we have color-scheme property because we invented it first; if time machine we'd have done the html meta first<br>
&lt;astearns> ack lea<br>
&lt;Zakim> lea, you wanted to react to lea<br>
&lt;astearns> ack emilio<br>
&lt;Zakim> emilio, you wanted to say that I don't understand why this is different from any other computed value change like em -> px, I think the current behavior seems reasonable<br>
&lt;TabAtkins> TabAtkins: and then the primary case would be whole page consistent<br>
&lt;emilio> If you have length design tokens you can't type them if you want to react to children font size changes. I get the confusion but I think the current behavior seems pretty reasonable and consistent with that.<br>
&lt;lea> TabAtkins: color-scheme affects UA-generated UI, so it's incredibly useful when you have overall dark elements<br>
&lt;astearns> ack fantasai<br>
&lt;Zakim> fantasai, you wanted to ask why someone would set color-scheme without also setting a color scheme with color and background color<br>
&lt;TabAtkins> emilio: [comment is read out]<br>
&lt;TabAtkins> fantasai: Tab is asserting the problem is you'd have a problem if you change color-scheme without setting background<br>
&lt;lea> +1 fantasai, I made that point too. Literally all use cases of element-specific `color-scheme` I have seen are surfaces and they have their own background<br>
&lt;TabAtkins> fantasai: don't understand why you'd do that anyway; color-scheme should always be set along with background<br>
&lt;TabAtkins> fantasai: we could be more explicit about that in the spec<br>
&lt;emilio> lea, fantasai, a non-theoretical use case is `forced-color-adjust: none`<br>
&lt;astearns> ack miriam<br>
&lt;emilio> This is what prompted the system color issue<br>
&lt;TabAtkins> emilio: so the idea that an author woudl flip the color scheme without changing the background seems odd. but flipping both seems liek a reasonable thing to do<br>
&lt;TabAtkins> miriam: i got on to say there are a lot of reasons to do this on a per-element basis<br>
&lt;fantasai> s/emilio/fantasai<br>
&lt;emilio> E.g., you have a subtree where you set `forced-color-adjust: none` and forget to set foreground / background and now stuff looks terrible<br>
&lt;fantasai> s/flipping both/flipping both on a subtree/<br>
&lt;TabAtkins> miriam: but i don't have much opinion on changing this for the specific issue. but i think we need a general solution for "i need a variable to hold something without resolving it"<br>
&lt;TabAtkins> miriam: more clear than registering vs not registering<br>
&lt;TabAtkins> q+<br>
&lt;TabAtkins> miriam: not clear to authors that holding it as a string requires unregistering; getting animations makes it break...<br>
&lt;TabAtkins> miriam: i think it's nice that setting color-scheme on the root changes the background anyway. so i agree with fantasai about that<br>
&lt;astearns> ack JoshT<br>
&lt;TabAtkins> miriam: i often want all the associated colros from a color scheme<br>
&lt;fantasai> +1 to miriam<br>
&lt;TabAtkins> JoshT: +1 to what miriam just said.<br>
&lt;lea> q+<br>
&lt;TabAtkins> JoshT: find it bizarre that color-scheme property is explained in the spec as choosing based on the element color scheme, but now light-dark() is using the page color scheme<br>
&lt;TabAtkins> (that's not correct)<br>
&lt;TabAtkins> JoshT: that's really confusing to me as an author<br>
&lt;astearns> ack TabAtkins<br>
&lt;lea> TabAtkins: light-dark() doesn't use the page color scheme, it uses the color-scheme of the element it's used on, the use case here is variables defined on the root, so they use the page theme<br>
&lt;lea> TabAtkins: to what lea and miriam were saying, i agree lazy resolve is a valuable capability<br>
&lt;lea> TabAtkins: that is in fact how the system colors work, canvastext resolves on that element at computed value time<br>
&lt;lea> TabAtkins: that's different than what we get with these design tokens<br>
&lt;miriam> +1, it's a general issue<br>
&lt;lea> TabAtkins: same underlying mechanism, additional mechanism about where and when they resolve<br>
&lt;lea> TabAtkins: having a switch that says "don't resolve this yet" would be good<br>
&lt;JoshT> +1<br>
&lt;lea> TabAtkins: e.g. a variable that can stay unresolved until explicitly resolved via some mechanism e.g. when used into a non-custom property<br>
&lt;lea> TabAtkins: this would give us this functionality, define your design tokens in the root, resolve at usage point<br>
&lt;lea> TabAtkins: that is also something we should be pursuing<br>
&lt;lea> TabAtkins: and that's the way to pursue it<br>
&lt;emilio> Agree, though it'd probably break animation, or we'd need to define animations between specified values<br>
&lt;astearns> ack lea<br>
&lt;bramus> +1 to Tab<br>
&lt;TabAtkins> lea: i agree ath if you set color-scheme you're generally setting background as well<br>
&lt;TabAtkins> lea: while to work aroudn *this* case you have to set declarations in a way that doesn't reflect your intent<br>
&lt;TabAtkins> lea: you have to *not* register your --accent-color property<br>
&lt;TabAtkins> lea: if you *do* register it, you have to redefine it at the elements that change color-scheme<br>
&lt;TabAtkins> lea: i think Tab's suggestion is great to do, but it doesn't fix the footguns<br>
&lt;TabAtkins> lea: it's great if there are workarounds to reach for, but there are alreayd workarounds<br>
&lt;TabAtkins> lea: problem is that colors just aren't working as authors are expecting<br>
&lt;TabAtkins> lea: all inherited color proeprties need to be redefined<br>
&lt;TabAtkins> lea: so it's not just about design tokens<br>
&lt;TabAtkins> lea: for system colors, on webkit they're defined as using light-dark()<br>
&lt;TabAtkins> lea: and Tab mentioned, not changing color-scheme on individual elements<br>
&lt;TabAtkins> lea: but since it affects UI like scrollbars, you can change all of them as well to match an otherwise dark element, like a code editor (often dark even if the overall UI is light)<br>
&lt;TabAtkins> lea: spelling underlines, etc<br>
&lt;TabAtkins> (i'm still with Emilio, the exact same concern occurs for all length properties that use ems)<br>
&lt;TabAtkins> astearns: sounds like we don't hav econsensus, but q is empty, let's take it back to the issue<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/13836#issuecomment-4443352102 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 13 May 2026 16:52:23 UTC