System-aware dark/light mode with localStorage persistence.
This is a digital download. No physical item will be shipped.
By purchasing you agree to our Terms of Service. A 30-day refund is available โ see our Refund Policy.
A single-file dark/light mode switcher that does everything right out of the box. On first visit it reads the user's prefers-color-scheme media query and applies the matching mode automatically โ no flash of wrong theme. After that, any manual toggle is saved to localStorage so the preference persists across sessions.
It works by toggling a data-theme attribute on the <html> element, which means it's compatible with any CSS custom-property-based theme. If you already have --color-bg, --color-text, and similar variables defined for light and dark, it just works.
The toggle button uses an animated SVG sun/moon icon that transitions smoothly between states. The entire file is under 800 bytes minified. No framework, no build step โ drop it in and it's done.