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

In v3 alpha, variant combinations like hover:before: aren't working #6016

Closed
MichaelAllenWarner opened this issue Nov 8, 2021 · 2 comments · Fixed by #6018
Closed

In v3 alpha, variant combinations like hover:before: aren't working #6016

MichaelAllenWarner opened this issue Nov 8, 2021 · 2 comments · Fixed by #6018

Comments

@MichaelAllenWarner
Copy link
Contributor

What version of Tailwind CSS are you using?

v3.0.0-alpha.2

What build tool (or framework if it abstracts the build tool) are you using?

webpack 5

What version of Node.js are you using?

v16

What browser are you using?

Tested in Chrome and Firefox

What operating system are you using?

macOS

Reproduction URL

https://play.tailwindcss.com/9hQ7AdVmRy

Describe your issue

In v2 I often used variant-combinations like hover:before:, but in v3 the :before and :after pseudo-element variants don't seem to work in combination with pseudo-class variants.

@RobinMalfait
Copy link
Contributor

Hey! Thank you for your bug report!
Much appreciated! 🙏

We introduced a new and more consistent addVariant API, which reverses the :hover and ::before pseudo's. This makes more sense in a lot of scenario's but it does introduce this breaking change.

To fix this right now, you can use before:hover: (flipped order). You can almost think of it as function calls before(hover(text-center)) where you evaluate from the inside out. E.g.: https://play.tailwindcss.com/2EjfqllUOh

However that might not be that convenient because it's a breaking change. On top of that, a selector that looks like this .class::before:hover will not work, since you can't hover over a before element.

That said, the linked PR #6018 will ensure that before and after pseudo elements are always at the end, regardless of the order you used them in.

Will keep this open for now until that PR gets merged.

@MichaelAllenWarner
Copy link
Contributor Author

Yes, that new order is the opposite of what I'd expect (and of what I'd previously used in v2), but now that I know about the change it seems fine, and I think the PR allowing for some flexibility makes a lot of sense.

david-crespo added a commit to oxidecomputer/console that referenced this issue Nov 17, 2021
* upgrade to tailwind 3.0 alpha, make config changes

* rewrite svg: w/ new addVariant API tailwindlabs/tailwindcss#5809

* first first-of-type:before: order issue (tw fix in next alpha)

tailwindlabs/tailwindcss#6112
tailwindlabs/tailwindcss#6016
tailwindlabs/tailwindcss#6018

* replace tailwindcss-children plugin with new custom addVariant

* oh yeah... use stroke-green-500

* each variant doesn't need its own plugin

* update yarn.lock after merging main
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

Successfully merging a pull request may close this issue.

2 participants