Live data from Hacker News

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

bram.us

1–10 of 74 posts

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

#2
I guess it's better than nothing, but this does not feel like a very CSS way of solving this problem. I think I'd rather write a separate block of styles for dark mode, the way you do for other media queries. Happy to hear why that's wrong though.

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

#4
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.

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

#5
My entire automatic light/dark support is, very early in the HTML:

    
then, in in-line CSS:

    @media (prefers-color-scheme:dark){body{background-color:#000;color:#eee}img{filter:brightness(.9)}}
I'm not seeing this new thing as a huge win so far.

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

#6
How is this better than using CSS variables for light/dark mode? With CSS variables you have better isolation for consistency with your entire color scheme, and you can extend it to supporting multiple themes (e.g. light, dark, blue).

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

#7

I guess it's better than nothing, but this does not feel like a very CSS way of solving this problem. I think I'd rather write a separate block of styles for dark mode, the way you do for other media queries. Happy to hear why that's wrong though.

It is not wrong, just annoying and error prone to write everything twice in two different places, but like you point out that is the CSS way.

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

#8
post #5

My entire automatic light/dark support is, very early in the HTML: then, in in-line CSS: @media (prefers-color-scheme:dark){body{background-color:#000;color:#eee}img{filter:brightness(.9)}} I'm not seeing this new thing as a huge win so far.

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?

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

#9
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.

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

#10

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.

God forbid someone adds practical features for common use cases to our beautiful turing tarpit.
Post reply on HN