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

[v4] space-y-* works differently with mb-* on a child #15699

Closed
thijsvandien opened this issue Jan 22, 2025 · 3 comments
Closed

[v4] space-y-* works differently with mb-* on a child #15699

thijsvandien opened this issue Jan 22, 2025 · 3 comments

Comments

@thijsvandien
Copy link

thijsvandien commented Jan 22, 2025

Under v3, I used to set for example space-y-4 as a base rule, and then -mb-1 on some child to slightly diverge from that. Under v4.0.0, it now seems to completely override the former.

Please see https://play.tailwindcss.com/RQmoDTdQga where there's a clear difference between the result of v3.4.15 and v4.0.0-beta.9 – I am not under the impression that it is at all browser dependent.

The (older) insiders build, f875ab9, still produced the same result as v3. Is this fairly recent change a bug or new expected behaviour? It would make sense not to support this sort of interplay, so it might rather be a matter of documentation.

Is it safe to change -mb-1 into mb-3 here, or should I expect that to break again in the future?

@thijsvandien thijsvandien changed the title [v4] space-y-* no longer works with mb-* on a child [v4] space-y-* works differently with mb-* on a child Jan 22, 2025
@wongjn
Copy link
Contributor

wongjn commented Jan 23, 2025

Slightly related comment (#15390 (comment)):

In v4 we changed how space-x-12 is implemented to be more performant. In v3 it was implemented like this .space-x-12 > :not([hidden]) ~ :not([hidden]) whereas in v4 it is implemented like this :where(.space-x-12 > :not(:last-child)).

Thus, the wrapping in :where() in v4 reduces the specificity of space-* so that the m-* takes precedence.

I expect the maintainers tolerated this breaking change between major versions but I would not expect the behavior to change again with the v4 major version now that it is stable.

@thijsvandien
Copy link
Author

Good find! That explains what's happening. Since there's already awareness of this, I guess the issue can be closed.

@tordans
Copy link

tordans commented Jan 30, 2025

JFYI there is a similar thing when using space-y-4 prose which I documented at tailwindlabs/tailwindcss-typography#374

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