Extend custom variants in plugins to vanilla CSS as well #13234
GermanJablo
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, it is possible to modify selectors like
:active
,:disabled
, etc., or create new ones like:hocus
.While these can be used in className, It would be great if these could also be used as native CSS selectors.
In CSS file:
Considering Tailwind is switching from PostCSS to Lightning CSS in v4, I think the way to achieve this would be with a custom transformation in Lightning CSS, right?
A little context about my use case:
I use
react-aria-components
, which does an excellent job of unifying and correcting the behavior of almost all selectors (:active, :hover, :focus-within, etc.). It does it by adding data attributes (data-pressed, data-hover, data-focus...).Additionally, they provide a
tailwindcss-react-aria-components
plugin that allows you to use selectors in tailwind in the way explained here instead of having to use data attributes.Something like this would allow you to use RAC without even thinking about the differences with actual browser selectors. You could define for example:
addVariant("focus-visible", ["[data-rac][data-focus-visible='true']", ":focus-visible:not([data-rac])"])
and if it could be used in both Tailwind and CSS, someone could migrate their styles from a simpler component library to RAC automatically.
Beta Was this translation helpful? Give feedback.
All reactions