[Bug]: `dark:` modifier doesn't seem to work with `Dialog`s
See original GitHub issueWhat package within Headless UI are you using?
What version of that package are you using?
v1.2.0
What browser are you using?
Chrome
Reproduction repository
https://github.com/leggettc18/devmarks-frontend-web/
Describe your issue
Pretty self explanatory with the title. Basically I have a Dialog, a div within that where the background color is specified, and a dark:
version as well. Only the light one seems to get added in. It actually does seem to work if I remove the bg-white
class while the rest of my site is in dark mode, but then the light version looks weird.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
Dark mode view modifiers no longer working #2127 - GitHub
Description. Dark mode no longer works with view modifiers. Regardless of device scheme, the view background colors will be "light".
Read more >Modifier - Android Developers
Order is significant; modifier elements that appear first will be applied first. ... Adds padding so that the content doesn't enter insets space....
Read more >AnimatedVisibility Doesn't Expand Height In Dialog in Jetpack ...
I tried animateContentSize() on Column and Card but it didn't work. And checked similar questions on StackOverflow but didn't found any useful ...
Read more >The Boolean modifier is not working - Blender Stack Exchange
If a boolean doesn't work it's probably because something in your geometry isn't making sense (even if it looks and renders fine).
Read more >10 Problems (and Solutions) for Blender Newbies - dummies
A notorious black stripe appears on models. Often when modeling, you run into a ... Edge loop select doesn't work. The issue of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey! Thank you for your bug report! Much appreciated! 🙏
Headless UI itself doesn’t care about which classes you apply and which you don’t. If you are experiencing issues with missing classes than make sure to include all the paths, where components with certain classNames live, to your purge config.
Additionally, I wanted to look at your reproduction repo but I have to sign up / sign in, so can’t help you with that one. That said, there is one thing you have to keep in mind with the
Dialog
is that it renders in a portal right in the<body>
tag. This means that if you are using adark
class, that you have to add it to thehtml
orbody
tag so that all children can use this information to render the dark/light mode.If you don’t like that approach, then you could look into using context for this. Here is a similar issue with React, but the same logic applies: https://github.com/tailwindlabs/headlessui/issues/280#issuecomment-828376470
This is because the headless UI dialog didn’t fall under vue pre-defined
<div id="app"></div>
. It create its own HTML afterid="app"
with id nameheadlessui-portal-root
. So the basic solution is to store yourdarkMode
boolean inside store and use with:class
attribute on your Dialog component like belowAfter this you can use tailwind dark classe without
:class