can i still use @apply in css modules in tailwind 4?
- User
can i still use @apply in css modules in tailwind 4?
- Assistant
No,
@applyis not available in Tailwind CSS v4. The Tailwind team removed@applyas part of their v4 redesign, along with the@layerdirective and several other features.In Tailwind v4, the recommended approach is to:
- Use utility classes directly in your markup - This is the primary way Tailwind is designed to be used
- Extract components - For reusable patterns, create actual components in your framework (React, Vue, etc.) rather than CSS abstractions
- Use CSS variables - For dynamic styling needs, Tailwind v4 has better CSS variable support
If you have existing code using
@applythat you're migrating to v4, you'll need to refactor it. The most straightforward approach is usually to move those utility combinations directly into your component markup or create proper component abstractions in your framework.This change was made to simplify Tailwind's architecture and improve performance, though it has been a point of discussion in the community since many developers relied on
@applyfor certain use cases.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.