Skip to content

Retheshgoud/DarkModePractice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

-darkmodepractice

As dark mode has gained a lot of traction recently, here's one of the darkmode approaches in JS using the LocalStorage πŸ‘‡

πŸ‘‰ Firstly,You’ll need to include an onclick method on your input to run the code to toggle the light/dark background.

πŸ‘‰ Then, set up my main class to cover the entire viewport width and height and added flex styling to center the toggle button and text.

πŸ‘‰ styling for the toggle button done

πŸ‘‰ Then create the code for the darkLight() onClick event. I created an if/else statement to toggle the dark class and save it to the local storage.

πŸ‘‰ Now we have the code to toggle a dark/light background, and when the user refreshes the browser, the background color will be saved to their local storage.πŸ‘