Tailwind Nested Styles Is not Work in Production in Nextjs(Tailwind V4.1.6 - Nextjs v15 app router) #18012
Unanswered
alirezagh73
asked this question in
Help
Replies: 1 comment
-
DiagnosisThe discrepency is due to the fact that Tailwind uses native CSS nesting that is transpiled in production. Given the source: .btn {
&-lg {
…
}
} DevAfter
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
We're using Tailwind CSS v4 with Next.js v15 (App Router) in our project.
We style our components using the @apply directive in combination with nested CSS selectors, like so:
💡 Code Example
✅ Expected Behavior
All nested styles (like .btn-lg, .btn-contained-primary, .btn-contained:disabled, etc.) should be included in the production CSS build.
❌ Actual Behavior
In development mode (next dev), everything works perfectly.
In production mode (next build && next start), all nested styles (e.g., &-lg, &-contained, etc.) are missing from the final CSS output.
📦 Project Environment
Tailwind-related config:
📌 Notes
It seems like Tailwind’s nesting support works correctly in dev mode but is not preserved in the production build process when using the native &-modifier nesting syntax.
Is this a known limitation or a misconfiguration on our side?
Any help would be appreciated 🙏
Beta Was this translation helpful? Give feedback.
All reactions