Comment by bradly
2 months ago
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.
You can do without javascript. Checkbox `:checked` + `label` trick for toggling states still works.
See: https://codepen.io/abdus/pen/bNpQqXv
Thanks, I’ll check this out!
Here's a version with a 3-way theme selector (light / system / dark) using radio inputs.
https://codepen.io/abdus/pen/yyOQpvE