light-dark()
developer.mozilla.org
light-dark()
1–10 of 13 posts
Re: light-dark()
#2color: light-dark(black, white);
Re: light-dark()
#3I think `black` and `white` should be switched here: color: light-dark(black, white);
Re: light-dark()
#4Re: light-dark()
#5Earlier quoted context omitted.
I don't think so. You want black text on a light theme/background.
But why is the order switched below? Functional notation: light-dark(light-color, dark-color)
It's not declaring the relative brightness of the two colours - I agree it could be documented a little less ambiguously with something like `light-theme-color`.
Re: light-dark()
#6
Or is this not precisely the same thing?https://html.spec.whatwg.org/multipage/links.html#rel-altern...
edit: with finish I mean use this for light/dark mode and fix it so that the preference chosen by the user is not immediately discarded after navigation. One doesn't discard user selected preferences. It is not done.
Re: light-dark()
#7@media (prefers-color-scheme: [name]) seems more extensible, but this feels simpler and easier to read.
Glad the function accepts custom properties (CSS "variables").
Should probably add a color property that doesn't use this function as a fallback for browsers that don't support it.
Re: light-dark()
#8I think `black` and `white` should be switched here: color: light-dark(black, white);
I don't think so. You want black text on a light theme/background.
Re: light-dark()
#9Earlier quoted context omitted.
But why is the order switched below? Functional notation: light-dark(light-color, dark-color)
It's not.. `light-color` refers to the colour you want presented if the user's preference is for a "light" theme. It's not declaring the relative brightness of the two colours - I agree it could be documented a little less ambiguously with something like `light-theme-color`.
Re: light-dark()
#10What if, in the future, we have more than two options (light and dark)? @media (prefers-color-scheme: [name]) seems more extensible, but this feels simpler and easier to read. Glad the function accepts custom properties (CSS "variables"). Should probably add a color property that doesn't use this function as a fallback for browsers that don't support it.
> The values for this feature might be expanded in the future (to express a more active preference for light color schemes, or preferences for other types of color schemes like "sepia"). As such, the most future-friendly way to use this media feature is by negation such as (prefers-color-scheme: dark) and (not (prefers-color-scheme: dark)), which ensures that new values fall into at least one of the styling blocks.
[0]: https://drafts.csswg.org/mediaqueries-5/#prefers-color-schem...