Re:CSS now has an if() conditional function
by bradly on Friday December 05, 2025 @12:20PM
(#46164282)
I recently implemented dark/light mode for the first time and was really surprised to find that in order to add a toggle I had to duplicate a both of vars/styles and use JavaScript. I'm looking forward to not having to deal with that cruft in the future.
[ Parent
| on HN ]
Re:CSS now has an if() conditional function
by hebelehubele on Friday December 05, 2025 @03:35PM
(#46166908)
You can do without javascript. Checkbox `:checked` + `label` trick for toggling states still works.
Re:CSS now has an if() conditional function
by bradly on Friday December 05, 2025 @08:55PM
(#46169811)
Thanks, I’ll check this out!
Re:CSS now has an if() conditional function
by hebelehubele on Saturday December 06, 2025 @05:10AM
(#46172118)
Here's a version with a 3-way theme selector (light / system / dark) using radio inputs.