
How I added dark mode to my website - flaviocopes
https://flaviocopes.com/dark-mode/
======
ucffool
I like the idea that dark mode is the default before load so that there isn't
a white-screen flash. Stealing it!

~~~
flaviocopes
If it was backend-powered I could check a cookie, but the site is static.
Since I made it dark-mode-first, I think it's a good compromise. Looking for
other ideas too

~~~
phillipseamore
We'll you could use the HTML element for the class. The other day I did an
example for a client this way: <html class="default"> <head> <script> if(
localStorage.getItem('dark-mode') !== null ) {
document.documentElement.classList.add('dark-mode'); } </script>

------
0xferruccio
Cool stuff flavio!!

