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

Peer variants only work if 'peer' element comes before 'peer-{modifer}:' element #7132

Closed
wfischer42 opened this issue Jan 19, 2022 · 2 comments

Comments

@wfischer42
Copy link

What version of Tailwind CSS are you using?
v3.0.15

What build tool (or framework if it abstracts the build tool) are you using?
postcss 8.4.5, Next.js 12.0.8

What version of Node.js are you using?

For example: v17.0.1

What browser are you using?
For example: Chrome

What operating system are you using?
macOS

Reproduction URL
https://play.tailwindcss.com/9tkBxIRJOq

Describe your issue
A peer variant seems to only work if the element with the peer class comes before the element with a peer-{modifier}: class. This is problematic element order can't always be easily rearranged to accommodate, particularly if it disrupts the tab-index flow.

@wfischer42 wfischer42 changed the title Peer variants only work if peer comes before in DOM Peer variants only work if 'peer' element comes before 'peer-{modifer}:' element Jan 19, 2022
@adamwathan
Copy link
Member

Hey! Yep this is intentional and is just a limitation of CSS — there are no selectors for targeting an element that comes before something, only after.

https://developer.mozilla.org/en-US/docs/Web/CSS/General_sibling_combinator

It's mentioned in the original PR (#4556) but it's not clear in the docs, will add a note there 👍🏻

@boompikachu
Copy link

For anyone looking for ways to target "before" sibling, one of the ways is to move all the "before" siblings to be "after" siblings and use flex order to rearrange the element. https://play.tailwindcss.com/Z6En7ZEn4u

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

3 participants