Repository navigation
Replies: 7 comments
|
It was never considered a best practice, but you can definitely still use it. This is what we recommend: https://tailwindcss.com/docs/styling-with-utility-classes#managing-duplication |
Short AnswerIn Tailwind CSS v4,
Official Guidance & Best Practices in v41. When to avoid
|
|
|
|
In Tailwind CSS v4, using Here is why and what you should use instead: Why
|
|
In Tailwind CSS v4, Key points for Tailwind v4:
@utility btn-primary {
background-color: var(--color-blue-600);
padding: 0.5rem 1rem;
border-radius: 0.375rem;
color: white;
}
|
|
To summarize the official team stance and the core ecosystem direction for Tailwind CSS v4:
|
|
It's still supported, but no longer the recommended default. The v4 docs still nudge you toward extracting components (React/Vue/etc.) or using In practice, in my projects I use it like this:
@utility btn {
@apply rounded-lg px-4 py-2 font-medium transition-colors;
}Then
One v4 gotcha: in a CSS file processed separately, So: utilities in markup → — |
Uh oh!
There was an error while loading. Please reload this page.
With Tailwind CSS v4 emphasizing utility-first workflows and CSS-first configuration, I'm wondering what the current recommendation is for using @apply.
Is it still considered a good practice for reusable component styles, or is it now discouraged in favor of composing utilities directly in the markup? I'd be interested to hear the team's recommendation and how others are using it in real projects.
All reactions