4 ms·
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
by tom_alexander 1y ago
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/ https://lyra.horse/blog/2025/08/you-dont-need-js/
- sevenseacat 1y agoyo that article is amazing