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