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.π
-
Notifications
You must be signed in to change notification settings - Fork 0
Retheshgoud/DarkModePractice
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Β | Β | |||
Β | Β | |||
Β | Β | |||
Β | Β | |||
Repository files navigation
About
No description or website provided.
Topics
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published