Live data from Hacker News

The Future of CSS: Easy Light-Dark Mode Color Switching with Light-Dark()

bram.us

21–30 of 74 posts

Re: The Future of CSS: Easy Light-Dark Mode Color Switching with Light-Dark()

#21
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 with Light-Dark()

#22
post #21

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 visu…

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 with Light-Dark()

#23
post #21

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 visu…

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 with Light-Dark()

#24

Oof. Unless I’m missing something, this is a convenience that doesn’t enable anything new and uses syntax/terms that don’t naturally generalize for future applications. It just embeds one recent trend in very specific, very rigid terms. This is how standards get bloated.

I agree. You can already do this using the space toggle technique: :root { --dark: ; } @media (prefers-color-scheme: dark) { --light: ; --dark:initial; } .example { color: var(--light, #000) var(--dark, #fff); }

Ah yes, the CSS Space Toggle. The way this works internally is a seemingly-unintended but very useful aspect of the CSS specification.

Re: The Future of CSS: Easy Light-Dark Mode Color Switching with Light-Dark()

#25

Oof. Unless I’m missing something, this is a convenience that doesn’t enable anything new and uses syntax/terms that don’t naturally generalize for future applications. It just embeds one recent trend in very specific, very rigid terms. This is how standards get bloated.

I agree. You can already do this using the space toggle technique: :root { --dark: ; } @media (prefers-color-scheme: dark) { --light: ; --dark:initial; } .example { color: var(--light, #000) var(--dark, #fff); }

That looks awful, but presumably if you are using sass instead of css you could define a light-dark macro already which does exactly that.

I wonder if custom functions might ever make their way to css.

Re: The Future of CSS: Easy Light-Dark Mode Color Switching with Light-Dark()

#27

How does this deal with the ternary of light/dark/high-contrast that a lot of sites are now using? I wish they would just enable features that are already in the browser that they've not put live, like grid-template-rows: masonry. All three major engines have the damned thing in there but it's not in release branch.

if browsers have support for a feature such as masonry, but it is not enabled in css spec does that mean it cannot be used? I recall seeing masonry in a tailwind talk, very neat!

Re: The Future of CSS: Easy Light-Dark Mode Color Switching with Light-Dark()

#28
I’m consistently amazed at how much energy has been put into the light/dark UI pattern for web and mobile apps. Way way more than was ever put into dealing with colorblindness or any other form of color adjustment imo.

It’s nice to have the choice but I also wonder what else might have been done with all that UX/UI design and SWE time.

Re: The Future of CSS: Easy Light-Dark Mode Color Switching with Light-Dark()

#29

Earlier quoted context omitted.

Interesting that you adjust the image brightness. I have everything set to dark mode, but I wouldn't want the images altered. Unless these are just navigational images on your site and you don't have any photos?

Images with a full dynamic range look too bright in the dark mode. I set them to 0.9 as well on my resources, otherwise the eyes are bleeding deep in the night.

There are multiple reasons for a user to want "dark mode":

* I just want everything to be dark on my screen because I like it.

* I am trying to use this device in a dark place.

* I want a dark, low-contrast background that doesn't compete with image colors.

The solutions to these three problems are all some kind of "dark mode" but each one needs a different solution. Sometimes one "dark mode" might work in conjunction with the user manually changing their brightness settings depending on the lighting in the environment, but not many people seem to design for that.

Re: The Future of CSS: Easy Light-Dark Mode Color Switching with Light-Dark()

#30
If I look at the times I’ve implemented dark mode — I see that the effect will be:

1. Less lines of code (seems like a good thing)

2. I will still need to use prefers-dark-mode for some of my changes.

Thus — the concept count is ratcheted up by 1 more thing, and no concept is taken away.

The “concept count” is ridiculously high already.

They’re spending money from an overdrawn account.

If you want to permanently increase the number of things that a bunch of people must learn, it has to have more value or power than this.

Post reply on HN