Open imericxu opened 4 months ago
I think it's preferable to use the pressed:
variant from the plugin in place of tailwind's default active:
variant. You'll get more consistent behavior across input modalities, and this should also fix your issue due to how they're ordered in the plugin. I think the behavior you're seeing is expected, since :active
and [data-hovered]
have the same specificity, it comes down to which comes last in the stylesheet, which would be [data-hovered]
since it comes from the plugin.
I understand the benefits that pressed
offers, however, the issue is that the plugin is disrupting the expected behavior, i.e., adding the plugin shouldn’t change existing behavior. In this case, the native hover state is being used because <button>
doesn’t have a programmatic isHovered
state. It seems like the native :hover
selector’s precedence is modified by the plugin, so it only makes sense that the :active
selector’s precedence is modified accordingly, even though the selector is discouraged, to maintain consistent behavior.
The specific use case where I want to keep using the :active
state is with links because the link components and press removes the native drag and drop ability.
The only potential solution I can think of is specifying a custom variant order in the plugin.
Prefixing all React Aria Components modifiers can resolve this issue.
Provide a general summary of the issue here
When the extension
tailwindcss-react-aria-components
is installed, having both:hover
and:active
selectors styling the same property doesn't work as expected.🤔 Expected Behavior?
:active
styles should override base and:hover
styles.😯 Current Behavior
If both
:hover
and:active
have different values forbackground-color
, the element will have the:hover
background color when the state is actually:active
.💁 Possible Solution
No response
🔦 Context
The
tailwindcss-react-aria-components
plugin helps to simplify the development process with autocompletion and shorter Tailwind selectors, but breaks existing code that uses the:active
selector with:hover
.🖥️ Steps to Reproduce
I couldn't figure out how to use
tailwind-react-aria-components
in CodeSandBox for free, but here's simple steps and code to reproduce:npx create-next-app@latest
with default optionsnpm i react-aria-components tailwindcss-react-aria-components
tailwindcss-react-aria-components
totailwind.config.ts
pluginssrc/app/page.tsx
with following code (I know<Button>
exists, this is just an example):tailwindcss-react-aria-components
pluginVersion
react-aria@3.21.1 & react-aria-components@1.1.1 & tailwindcss-react-aria-components@1.1.1
What browsers are you seeing the problem on?
Chrome, Safari
If other, please specify.
No response
What operating system are you using?
macOS
🧢 Your Company/Team
No response
🕷 Tracking Issue
No response