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
Describe your issue
I have a Listbox component within a Dialog. The Listbox component is styled with the ui-open utility class from @headlessui/tailwindcss. Expected:ui-open styles on the Listbox only take effect when the Listbox itself is open, regardless of where it is in the app hierarchy. What happens: Within a Dialog component, Listbox always has the ui-open styles active, inheriting the need for them from the Dialog's open state, not from the Listbox's open state.
What package within Headless UI are you using?
"@headlessui/react": "latest",
"@headlessui/tailwindcss": "^0.2.0",
What browser are you using?
Chrome
Reproduction URL
I really tried to provide a reproduction but I can't get the "@headlessui/tailwindcss" plugin to work at all in the starting project: https://codesandbox.io/p/devbox/my-tailwind-vwrs78?file=%2Fsrc%2FApp.jsx%3A12%2C25
Unfortunately the "ui-open"classes have no effect in that sandbox. Would appreciate tips on how to make it work there in the config so that I could accurately reproduce it for you!
In the above sandbox, it is expected that when the Listbox is opened, Button bottom border radius is set to 0 and the background goes light blue with @headlessui/tailwindcss util classes: <Listbox.Button className="rounded-t-md rounded-b-md ui-open:rounded-b-none bg-white ui-open:bg-sky-300">
The text was updated successfully, but these errors were encountered:
The problem you are seeing is that the ui-open also applies because the Dialog also exposes that information. To solve this, you can explicitly mark the bg-white with ui-not-open:
It's a bit of an unfortunate situation, but this should solve your issue.
If this still won't work, then you can fallback to using JS based values using render props: https://headlessui.com/react/listbox#using-render-props
We are aware of this inconvenience, and to handle this in a more explicit and reliable way we made the following changes to the next versions of Headless UI and Tailwind CSS (both are currently in an alpha stage, but wanted to share this with you already):
In Headless UI v2, we expose these values as data attributes directly, this means that you will be able to use data-[open]:… directly.
In Tailwind CSS v4, data attributes will be available as data-open:… which is easier to type than data-[open]:….
@RobinMalfait truly, thank you for taking the time for such a comprehensive response! ui-not-open class indeed did the trick and the inputs within the dialog correctly get styled only when they are open. Appreciate the sneak peek to future features as well!
Would you perhaps have at hand any online codesandbox where @headlessui/tailwindcss plugin is working alongside @headlessui/react? It would be a hugely helpful asset to make online demos of HeadlessUI components for my team.
Describe your issue
I have a Listbox component within a Dialog. The Listbox component is styled with the
ui-open
utility class from @headlessui/tailwindcss.Expected:
ui-open
styles on the Listbox only take effect when the Listbox itself is open, regardless of where it is in the app hierarchy.What happens: Within a Dialog component, Listbox always has the
ui-open
styles active, inheriting the need for them from the Dialog's open state, not from the Listbox's open state.What package within Headless UI are you using?
"@headlessui/react": "latest",
"@headlessui/tailwindcss": "^0.2.0",
What browser are you using?
Chrome
Reproduction URL
I really tried to provide a reproduction but I can't get the "@headlessui/tailwindcss" plugin to work at all in the starting project: https://codesandbox.io/p/devbox/my-tailwind-vwrs78?file=%2Fsrc%2FApp.jsx%3A12%2C25
Unfortunately the "ui-open"classes have no effect in that sandbox. Would appreciate tips on how to make it work there in the config so that I could accurately reproduce it for you!
In the above sandbox, it is expected that when the Listbox is opened, Button bottom border radius is set to 0 and the background goes light blue with @headlessui/tailwindcss util classes:
<Listbox.Button className="rounded-t-md rounded-b-md ui-open:rounded-b-none bg-white ui-open:bg-sky-300">
The text was updated successfully, but these errors were encountered: