3 ms·
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/style
by bradly 10mo 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.
- hebelehubele 10mo agoYou can do without javascript. Checkbox `:checked` + `label` trick for toggling states still works. See: https://codepen.io/abdus/pen/bNpQqXv https://codepen.io/abdus/pen/bNpQqXv
- bradly 10mo agoThanks, I’ll check this out!
- hebelehubele 10mo agoHere's a version with a 3-way theme selector (light / system / dark) using radio inputs. https://codepen.io/abdus/pen/yyOQpvE https://codepen.io/abdus/pen/yyOQpvE