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

Pseudoclass styles apply at wrong level with tailwind v4 #376

Closed
nathonius opened this issue Feb 1, 2025 · 4 comments
Closed

Pseudoclass styles apply at wrong level with tailwind v4 #376

nathonius opened this issue Feb 1, 2025 · 4 comments

Comments

@nathonius
Copy link

nathonius commented Feb 1, 2025

What version of @tailwindcss/typography are you using?

v0.5.16

What version of Node.js are you using?

v20.17.0

What browser are you using?

Firefox

What operating system are you using?

Windows (WSL)

Reproduction repository

Tailwind play: https://play.tailwindcss.com/P8iFbnFepo
Repo: https://github.com/nathonius/astro-site/tree/tailwind-upgrade-issue-repro

Describe your issue

Upon upgrading to Tailwindcss v4, I'm finding that classes documented here in the typography repo are no longer applying correctly.

I have the following structure to apply simple colors and hover colors for links:

<main class="prose prose-a:text-primary hover:prose-a:text-secondary m-2 md:min-w-[65ch]">
  <slot />
</main>

This is modeled directly after the example in the docs. This works great with Tailwind v3, but in v4 now the :hover is taking precedence; instead of the color of the links changing when I hover the link, the color of the links changes when I hover the main element.

I don't know if this is truly a bug or just a documentation issue; swapping the order of the prose-a and hover classes makes it work again:

<main class="prose prose-a:text-primary prose-a:hover:text-secondary m-2 md:min-w-[65ch]">
  <slot />
</main>

It may be enough to remove this line "When stacking these modifiers with other modifiers like hover, you most likely want the other modifier to come first:" and update the code example; honestly the way it works now seems more accurate anyway.

@nathonius nathonius changed the title Pseudoclass styles apply at wrong level Pseudoclass styles apply at wrong level with tailwind v4 Feb 1, 2025
yshrsmz added a commit to yshrsmz/yshrsmz.github.io that referenced this issue Feb 2, 2025
@DanielOberlechner
Copy link

Does anybody know when the TailwindCSS Typography plugin will be fully compatible with TailwindCSS v4?
As far as I'm informed at the moment it doesn't work is that correct?
Do we have a date or a time frame in mind when the support will be here?

Kind regards,
Daniel Oberlechner

@nathonius
Copy link
Author

Does anybody know when the TailwindCSS Typography plugin will be fully compatible with TailwindCSS v4?
As far as I'm informed at the moment it doesn't work is that correct?
Do we have a date or a time frame in mind when the support will be here?

Kind regards,
Daniel Oberlechner

I would say it mostly works with a few caveats like this one. That's the only issue I've noticed and I've now updated to tailwind v4.

@adamwathan
Copy link
Member

Hey! Yeah this is one of the changes in v4:

https://tailwindcss.com/docs/upgrade-guide#variant-stacking-order

Need to update the README to probably show both a v3 and v4 example.

@philipp-spiess
Copy link
Member

Updated the readme, thanks!

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

4 participants