You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can I set the class or data attribute on the body or another element?
Nope. If you have a good reason for supporting this feature, please open an issue.
Using Tailwind's important option with the selector strategy causes a selector issue with next-themes' html class or data attribute.
I think it might be interesting to allow defining on what element the theme-attribute should be applied to. This would allow using next-themes on a more granular level than just for the entire page 🤔
This would make it more complex though, @pacocoursey what are your thoughts on this?
Any progress? This is an important feature when trying to use next-themes in web components or browser extensions. They are expected to restrict the theme within their subtrees without modifying the classNames of the global html element.
As mentioned in the FAQ:
Using Tailwind's
important
option with the selector strategy causes a selector issue with next-themes' html class or data attribute.Example:
Currently:
⚠ Results in an unusable dark mode selector of
html .dark
. The.dark
selector must be a child of the important selector (html
).After proposed feature:
✔ Results in a working dark mode selector of
html .dark
Further reading
The issue is also mentioned here: tailwindlabs/tailwindcss#9438
The text was updated successfully, but these errors were encountered: