Web Basics
Dark Mode Toggle
A theme switch that remembers your choice — the feature every site wants.
Add a light/dark switch that respects the visitor's system setting and remembers what they picked. The trick is CSS variables plus one attribute on the page — you'll see how real theming works.
What's inside
- Toggle light and dark with CSS variables
- Remembers the choice in localStorage
- Falls back to the OS preference on first visit
- One data-attribute drives the whole palette
- No flash of the wrong theme
Quickstart
$ curl -LO https://devai.io/downloads/dark-mode-toggle.zip$ unzip dark-mode-toggle.zip && cd dark-mode-toggle$ open index.html # or just double-click the file
about this tutorial
A devai.io starter tutorial — the theming pattern behind this very site.
More in Web Basics
view allWeb Basics
Tip Calculator
Your first interactive page: type a bill, see the tip update live.
HTMLCSSJavaScript
View template zip + preview
Web Basics
To-Do List
Keep a list, tick things off, and have it still be there after a refresh.
HTMLCSSJavaScriptlocalStorage
View template zip + preview
Web Basics
Countdown Timer
Count down to any moment — days, hours, minutes, seconds, ticking live.
HTMLCSSJavaScriptDates
View template zip + preview