Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


FWIW 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/


yo that article is amazing




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: