Solution: Programmatically Detect Dark Mode using React Hook #10168
elucidsoft
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I couldn't find a good answer to this, so I thought I would share this code snippet in case anyone else had this problem. I have a text editor component that uses it's own themes, and I wanted to switch the theme dynamically based on the Tailwind dark mode or light mode to match better. To do that I needed a way to dynamically detect if the Tailwind Dark mode was enabled, or not. I also needed to be able to watch for a change, in case they switched themes.
Beta Was this translation helpful? Give feedback.
All reactions