4 ms·
I would tolerate some js to implement dark mode with a class rather than a media query. It allows more control with a toggle if user wants some site dark some l
by eric-burel 1y ago
I would tolerate some js to implement dark mode with a class rather than a media query. It allows more control with a toggle if user wants some site dark some light.
Edit: it's covered in the article actually.
- tom_alexander 1y agoFWIW you can add a light/dark toggle button without any javascript. You only need javascript if you want to persist that preference in localStorage. Here is an article that was posted to HN which implements the three-state (auto/light/dark) toggle in HTML and CSS only: https://lyra.horse/blog/2025/08/you-dont-need-js/ https://lyra.horse/blog/2025/08/you-dont-need-js/
- sevenseacat 1y agoyo that article is amazing