Simple light/dark mode
marcamos.com·19w
Preview
Report Post

Demo

The code below is what I use on this website – scroll/swipe down to the footer and play with the options within Color scheme to see it in action.

Code

What follows will allow a visitor to choose between light mode, dark mode, or the mode their device is currently in (which I’ve labeled System). This System option is useful if the visitor’s device is configured to automatically switch between light and dark modes based on the time of day.

HTML

Fairly straightfoward HTML; mark it up however you see fit, just make sure the <input> elements keep these attributes.

<label>
<input type="radio" name="color-scheme" value="light dark">
System
</label>
<label>
<input type="radio" name="color-scheme" value="light">
Light
</label>
<label>
<input type="radio" name...

Similar Posts

Loading similar posts...