Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for @headlessui/tailwindcss prefixes in inner classes #811

Closed
gbirman opened this issue Jul 3, 2023 · 2 comments
Closed

Support for @headlessui/tailwindcss prefixes in inner classes #811

gbirman opened this issue Jul 3, 2023 · 2 comments

Comments

@gbirman
Copy link

gbirman commented Jul 3, 2023

Although selectors such as ui-active for HeadlessUI components are working on parent components as of #741, the selectors do not work for inner elements, even though the syntax is supported on the HeadlessUI documentation. However, I've only tested with the Switch component. You can find more details and a code sandbox in the issue I created in the headless ui repo, where the verdict was that the problem lay with twin.macro.

@ben-rogerson
Copy link
Owner

Thanks I'll take a look and get back to you

@ben-rogerson
Copy link
Owner

ben-rogerson commented Jul 18, 2023

Hey there

Looks like twin is correctly generating the classes and this is due to a bug with styled-components and how it interprets the selector.
I updated styled-components to v6.0.4 and the Switch component became togglable.

After the upgrade you'll see that pseudo selectors won't be working correctly but adding sassyPseudo: true to your twin config will fix it for now. The next version of twin won't require this - it's due out within a few days.

The selector that isn't supported in styled-components < 6 is:

":where([data-headlessui-state~=\"checked\"]) &": { ... }

Related #818

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants