Skip to content

Nested CSS utilities and @apply rules fails #16935

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

Closed
willans opened this issue Mar 4, 2025 · 3 comments · Fixed by #16940
Closed

Nested CSS utilities and @apply rules fails #16935

willans opened this issue Mar 4, 2025 · 3 comments · Fixed by #16940
Labels

Comments

@willans
Copy link

willans commented Mar 4, 2025

What version of Tailwind CSS are you using?

For example: v4.0.9

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

Vite 6.2.0

What version of Node.js are you using?

For example: v22.0.0

What browser are you using?

N/A

What operating system are you using?

macOS

Reproduction URL

https://play.tailwindcss.com/zVH1cgIGl7

Describe your issue

I'm creating a bunch of utility classes in a project, and I stumbled across a bug in which utility classes are not being generated, if they're also used within some custom components/classes.

Within the example, all of the setups work except Example 2. Within Example 2, no class is being generated for 'type-block-1', despite it being in the markup.

I've narrowed it down to when there's multiple @apply rules within the same block. This also only happens with these newly defined utility classes. If the nested @apply uses a default Tailwind utility (e.g. rotate-45), then the issue doesn't persist. So it doesn't look like it's an issue with the structure of the CSS.

At first I thought this was my own personal setup, but I've managed to recreate within Tailwind Play.

If I'm doing anything glaringly obvious, let me know.

@philipp-spiess
Copy link
Member

Oh wow that's a fun one. Looks like somehow the nested usage of @apply swallows the @utility definition. Thanks for the repro, we'll look into it!

@philipp-spiess
Copy link
Member

Fixed in main, will be out with the latest patch release. Thank you!

@willans
Copy link
Author

willans commented Mar 4, 2025

Excellent. Thanks for the speedy response and fix @philipp-spiess, appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants