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.👍