News for hackers. Stuff that matters.
Re:The Future of CSS: Easy Light-Dark Mode Color Switching w... by jjcm on Monday October 09, 2023 @07:28PM (#37826760)
I've done a LOT of dark mode work, to the point where I'd consider myself an expert here[1].

I'm not a fan of this. This solves one tiny aspect of the larger problem in a non-scalable way that will inevitably lead to bloat and inflexibility. It's a really a naive approach that hasn't taken into account design at scale, nor the future of where design is heading.

Typically when doing theming, you have two axes - a visual mode axis (i.e. light/dark/high contrast/colorblind modes/etc) and a theme axis (i.e. docs/sheets/slides, each with a different brand color). While this does solve an aspect of the visual mode axis, as soon as you add either a new theme or a visual accessibility mode, you'll be forced to refactor. I see that as codesmell.

I also don't think this helps drive a better future of theming support. If we think about the future of theming, what we see today is a convergence of design patterns. Nearly everyone is doing theming at scale in at least roughly the same way (a semantic token layer that points to different primitive colors depending on the theme), and the differences between implementations continues to diminish over time. The convergence of patterns is a good thing - it means more code can be shared.

If you wanted to actually solve theming, what you should work for is not a constrained helper function like light-dark(), but instead a shared token schema. Today nearly every company has their own token schema and different ways of naming things in the semantic token layer. If we had a shard language here, not only would it be trivial to add light/dark theming (just redefine a few variables that are already provided for you), code could be shared between sites and inherit the theming/branding.

[1] Most recently leading Figma's dark mode stream, and currently leading their variables feature work to enable others to easily do light/dark/etc. I've consulted with 50+ enterprise tier companies on their theming. Also contributed to the W3C design token proposal for theme/mode support: https://github.com/design-tokens/community-group/issues/210. Previously worked on Jira's dark mode + a few other projects.

Re:The Future of CSS: Easy Light-Dark Mode Color Switching w... by jjcm on Monday October 09, 2023 @07:51PM (#37826921)
FWIW, I added a comment here around a simple but more flexible proposal, that allows for easy light/dark theming via this approach, but would at least scale (and would allow for color-scheme's custom identifier support to be useful): https://github.com/w3c/csswg-drafts/issues/7561#issuecomment...
Re:The Future of CSS: Easy Light-Dark Mode Color Switching w... by qingcharles on Monday October 09, 2023 @08:17PM (#37827086)
That link goes deep. I agree about the tokenizing.

I hate that we've picked off all the easy work on web design and now we're into problems we never even imagined 10 years ago, e.g. multiple visual modes, differing color spaces etc. This stuff is getting really, really hard to do well and do it right -- it is very easy to make things worse for a lot of users, rather than better.

Re:The Future of CSS: Easy Light-Dark Mode Color Switching w... by stevage on Monday October 09, 2023 @09:11PM (#37827497)
Remember that the projects you work on are not typical of most CSS usage in the world.

For small projects that never need to "scale", this looks handy.

Re:The Future of CSS: Easy Light-Dark Mode Color Switching w... by hyperhopper on Monday October 09, 2023 @10:44PM (#37827998)
Even if you never need to scale, Having light/dark & high contrast is just having basic features and complying to the law. If your site has 50 users it should have these, and this new light/dark switch is still inappropriate for even this basic use case.
Re:The Future of CSS: Easy Light-Dark Mode Color Switching w... by extra88 on Tuesday October 10, 2023 @08:08AM (#37831046)
What law? The U.S.'s Section 508 and other laws and regulations based on WCAG, don't require that sites honor `prefers-color-scheme` or to work correctly when `forced-colors` is active.

Nevertheless, it's a good idea to do so (though if a site honors `prefers-color-scheme` it should also have a setting so the user can choose to have that site not match their system's color scheme setting).

Re:The Future of CSS: Easy Light-Dark Mode Color Switching w... by jjcm on Monday October 09, 2023 @11:18PM (#37828167)
Very true! Nonetheless this approach would also break compatibility with `color-scheme`'s custom identifiers, which is just bad in general for CSS even for these small projects. The alternative proposal I put together here would allow this to scale and still provide a helper function for small projects to use: https://github.com/w3c/csswg-drafts/issues/7561#issuecomment...
Re:The Future of CSS: Easy Light-Dark Mode Color Switching w... by wldcordeiro on Tuesday October 10, 2023 @12:08AM (#37828425)
I appreciate that you not only have a nuanced critique but an alternative proposal as well.
Re:The Future of CSS: Easy Light-Dark Mode Color Switching w... by stevage on Tuesday October 10, 2023 @12:40AM (#37828557)
I do like your alternative proposal.

For the viewers at home:

:root {

  color-scheme: light dark high-contrast;
}

body {

  background: scheme(light #eee, dark #333, high-contrast #fff);

}
Re:The Future of CSS: Easy Light-Dark Mode Color Switching w... by beezlewax on Tuesday October 10, 2023 @12:46AM (#37828587)
Jira has a dark mode??
Re:The Future of CSS: Easy Light-Dark Mode Color Switching w... by adiabatty on Wednesday October 11, 2023 @02:43AM (#37841667)
Does now. It's pretty nice.
Re:The Future of CSS: Easy Light-Dark Mode Color Switching w... by the_gipsy on Tuesday October 10, 2023 @03:07AM (#37829302)
> shared token schema

Could you explain or give an example of what this is?

Re:The Future of CSS: Easy Light-Dark Mode Color Switching w... by c-hendricks on Tuesday October 10, 2023 @08:52AM (#37831419)
theme-ui (https://theme-ui.com/getting-started), mui's `Theme` (https://mui.com/material-ui/customization/default-theme/), bootstrap's variables

Basically, when you think in purpose instead of colors.

Re:The Future of CSS: Easy Light-Dark Mode Color Switching w... by grncdr on Tuesday October 10, 2023 @05:15AM (#37829978)
> If you wanted to actually solve theming, what you should work for is not a constrained helper function like light-dark(), but instead a shared token schema. Today nearly every company has their own token schema and different ways of naming things in the semantic token layer. If we had a shard language here, not only would it be trivial to add light/dark theming (just redefine a few variables that are already provided for you), code could be shared between sites and inherit the theming/branding.

Isn't that the idea behind https://open-props.style/ (and https://theme-ui.com/ in JS land)?

I think it's a great idea, but hampered by the lack of adoption incentives for the very people that need to adopt it for it to become successful (design system/component library authors). It introduces constraints, but the promised interoperability is not really beneficial to the people who need to work within those constraints.

Re:The Future of CSS: Easy Light-Dark Mode Color Switching w... by c-hendricks on Tuesday October 10, 2023 @08:43AM (#37831326)
There's millions of downloads every week for mui and bootstrap. Anyone using them is using something like theme-ui.
Re:The Future of CSS: Easy Light-Dark Mode Color Switching w... by padjo on Tuesday October 10, 2023 @05:40AM (#37830099)
I agree this looks like it will be of questionable use at scale. That said I don’t see a shared token schema ever achieving much. Those sorts of efforts usually flounder because there’s little incentive for adoption until a critical mass is achieved
Re:The Future of CSS: Easy Light-Dark Mode Color Switching w... by bramus on Tuesday October 10, 2023 @07:23AM (#37830740)
(Hi, author of the post/article here)

> This solves one tiny aspect of the larger problem in a non-scalable way that will inevitably lead to bloat and inflexibility. It's a really a naive approach that hasn't taken into account design at scale, nor the future of where design is heading.

Note that `light-dark()` isn’t the end goal here. As discussed within the CSS WG, the end goal is to have a generic function `schemed-value()` to give you what you want.

I realize this wasn’t included in the post, so I’ve added a new section to the post with this information: https://www.bram.us/2023/10/09/the-future-of-css-easy-light-...

I hope this addresses your concern. If not, feel free to let me (or the CSS WG for that matter) know.