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
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
cucaracha
cucaracha2y ago
No. just css modules
shaaah
shaaah2y ago
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
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
cucaracha
cucaracha2y ago
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?
shaaah
shaaah2y ago
For this scenario you could also use useLayoutEffect
Want results from more Discord servers?
Add your server