Easiest way to toggle dark mode or light mode in react or next app?
I want to change my css variables to dark mode or light mode colors. Should i put my global css variables in __next and use a selector to change the css variable values? Are there any other ways that or better or easier?
6 Replies
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
No. just css modules
This might help you if you are using :root for variables
https://dev.to/ananyaneogi/create-a-dark-light-mode-switch-with-css-variables-34l8
DEV Community 👩💻👨💻
Create A Dark/Light Mode Switch with CSS Variables
Step by step guide on how to create a dark-light mode switch with CSS variables in your website
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
ill check this out
hmm yea basically what im trying to do right now
not sure how i should be accessing dom elements in react components
should it be in a useeffect?
For this scenario you could also use useLayoutEffect