DEV Community

Cover image for Dark mode in your web app
Nur Ilyas
Nur Ilyas

Posted on

Dark mode in your web app

Implement dark mode in your web app. #html #css #javascript

Step 1. Set background and text colors using CSS variables.

Step 2. Apply variables to elements.

Step 3. Toggle the dark mode class on document's body and save the user's preference in local storage.

Step 4. Add a script at the start of 'body' tag to load dark mode preference.

Top comments (0)