Dark mode, also called Light-on-dark color scheme, is a color scheme that uses light-colored text, icons, and graphical user interface elements on a dark background and is often discussed in terms of computer user interface design and web design.
The idea behind dark mode is that it reduces the light emitted by device screens while maintaining the minimum color contrast ratios required for readability.
What are the advantages of Dark Mode?
Can use less energy on the using device
Can potentially reduce eye strain and dry eyes in low-light conditions
Less blue light emitted from your phone – which can keep you awake if you use your device before heading to bed
How to implement dark mode in your website?
Lets start with a html skeleton and a button and a linked stylesheet and script
<!DOCTYPE html><htmllang="en"><head><metacharset="UTF-8"><title>Dark Mode</title><linkrel="stylesheet"href="style.css"></head><body><buttonclass="btn"id="toggleBtn">
Toggle Dark Mode
</button><script src="script.js"></script></body></html>
Now let's address the main issue. First we will be adding the css variables for the colors (lets call them primary and background) and override the required color(s) in the dark mode