News for hackers. Stuff that matters.
Re:CSS Only dark mode by lloydatkinson on Saturday June 24, 2023 @04:33AM (#36456730)
It’s ironic it says that the user should set the theme themselves via their OS because the author doesn’t like to use buttons on sites to do it.

The vast majority of users don’t know how to do that.

Re:CSS Only dark mode by butz on Saturday June 24, 2023 @04:40AM (#36456771)
Not sure about Windows or macOS, there users probably stick with default setting anyway, but here on GNOME I have quick access to "Dark Style" toggle in quick settings, just one click away.

We could start a long discussion, should websites just follow system settings, or add their own custom controls, where you have different settings for each website. Along with dark mode switching, we should consider accessibility controls, and cookie settings too.

From a developer standpoint I'd prefer to reflect system settings.

Re:CSS Only dark mode by dulvui on Saturday June 24, 2023 @04:40AM (#36456769)
Original author here. I don't like the idea of using JS on my website and I don't think that it is possible to create a light/dark mode switch with only CSS. But you are right, most users don't know how to do that.
Re:CSS Only dark mode by jiggywiggy on Saturday June 24, 2023 @04:43AM (#36456782)
Would be perfectly reasonable to use js over this feature.
Re:CSS Only dark mode by dulvui on Saturday June 24, 2023 @04:47AM (#36456807)
Yes for sure, but my personal policy is not using JS. Anyway my site doesn't have so many visitors ;-) People come, stay for a few seconds and then leave forever.
Re:CSS Only dark mode by jiggywiggy on Saturday June 24, 2023 @09:06PM (#36464248)
Hahah old school hate for js. Very good.
Re:CSS Only dark mode by FireInsight on Saturday June 24, 2023 @04:47AM (#36456806)
However, it would probably be possible with very minimal JS a la how Tailwind does it, toggling a .dark class in the body element and setting the dark mode variables and colors there.
Re:CSS Only dark mode by butz on Saturday June 24, 2023 @04:48AM (#36456818)
But adding onclick and window.open() JS functions is somehow justifiable, over using simple <a> links? Of course, there might be some specific case you are solving here, so it would be very educational to hear this out.
Re:CSS Only dark mode by danielheath on Saturday June 24, 2023 @04:49AM (#36456825)
You can! Trick is to use the checkbox:selected hack to apply styles, in addition to the colour-scheme media query.
Re:CSS Only dark mode by CrimsonRain on Saturday June 24, 2023 @04:51AM (#36456838)
It is possible; just too convoluted/subpar imo. You can use a checkbox's check/uncheck status. One such codepen from quick google: https://codepen.io/shadowfaxrodeo/pen/JjbzNMz
Re:CSS Only dark mode by dulvui on Saturday June 24, 2023 @04:54AM (#36456853)
Cool thank you for sharing this! I might implement this on my site.
Re:CSS Only dark mode by CrimsonRain on Saturday June 24, 2023 @04:47AM (#36456810)
If one can't set lightness mode in their OS, they almost certainly won't benefit with a button on the site.

Sites should follow the browser scheme (which usually follows OS) and can optionally provide a button to switch. This is possible with CSS only but too convoluted; one liner JS is enough for such optional cases.

Re:CSS Only dark mode by pessimizer on Saturday June 24, 2023 @05:33AM (#36457100)
> If one can't set lightness mode in their OS, they almost certainly won't benefit with a button on the site.

What could you possibly be basing this theory on?

Re:CSS Only dark mode by youssefabdelm on Saturday June 24, 2023 @04:57AM (#36456870)
For me what's compelling here is "auto-dark mode". As a user I don't want to keep making CSS changes to every site I visit to that's light mode. I wish the web in general had these 2 styles and automatically inferred from my device that "This person is a vampire, give him dark mode"
Re:CSS Only dark mode by 7znwjshsus on Saturday June 24, 2023 @05:43AM (#36457147)
Those who don't know how to do that probably don't care anyway.
Re:CSS Only dark mode by jansan on Saturday June 24, 2023 @05:46AM (#36457167)
If they don't know, how do you know they don't care? I find that if I show people a nice feature they did not know about, they often like it and then use it. It's just that not everyone is a tinkerer who first feels the need to dive into the features of a new software.