Overriding light/dark mode for a sub-tree of the document #11999
jamesbvaughan
started this conversation in
Ideas
Replies: 1 comment 2 replies
-
You could consider using a Tailwind plugin that creates a variant that behaves like addVariant('foo', '.dark &:not(.light *)'); |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm working on a project that uses the
class
strategy for manually controlling light/dark mode and then using Tailwind prefixes (as inclassNames="dark:bg-black-100 bg-white"
). We have a few components that implement dark and light styling, but there are some contexts where we want them to always be in light mode, regardless of whether the rest of the app is in light mode.I could implement this by setting light and dark styles manually (
classNames={darkMode ? "bg-black-100" : "bg-white"}
), but these are complex components with many descendants that would also need to be updated.I think that the ideal solution for my use case would be to have a
light
class that I could apply at any point in the tree, and all descendant nodes would use light mode styling, overriding the surrounding document's theme.Is this something that's already possible? If not, would it be a reasonable feature to add?
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions