Design comparison
Solution retrospective
Any feedback is welcome. :)
Community feedback
- @abe-m1Posted about 4 years ago
Hey Jesus, Great job on the solution.
I tried the same approach for the JS file where I toggled classes on and off. But I found it was a lot of code.
So I came across a solution where you...
-
use CSS variables to define the light colors.
-
Then when the toggle is switched on it adds a data-attribute in the HTML.
-
and then in the css there is a class for the newly added data-attribute inside which the previous defined CSS variables are redefined with the dark colors.
It made the code cleaner by having to write less lines of code and use less classes.
this is the article i got it from: (https://raoulkramer.de/css-dark-mode-light-mode-rethought/)
1 -
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord