@apply directive.
Integration
Both@node-core/ui-components and apps/site configure Tailwind through PostCSS using @tailwindcss/postcss:
*.module.css files and replaces @apply directives with the corresponding CSS output.
Using @apply
Inside a CSS Module, use@apply to reference Tailwind utility classes:
When to use Tailwind vs. custom CSS
| Situation | Recommendation |
|---|---|
| Layout, spacing, sizing, color | Use @apply with Tailwind utilities |
| Typography scale, font weight | Use @apply with Tailwind utilities |
Pseudo-states (:hover, :focus) | Use Tailwind variant utilities via @apply |
Complex clip-path or custom transforms | Write plain CSS |
| CSS custom properties / design tokens | Write plain CSS |
| Animations with specific keyframes | Write plain CSS @keyframes |
Avoid writing plain CSS for anything Tailwind covers. This keeps the design system consistent and avoids magic numbers scattered across stylesheets.
Responsive utilities
Tailwind’s responsive prefixes (md:, lg:) work inside @apply:
Dark mode
Tailwind dark mode utilities are available with thedark: prefix:
next-themes to manage the active theme and applies a dark class to the root element.
Compilation
For@node-core/ui-components, CSS is compiled separately from TypeScript:
dist/ alongside the compiled JavaScript.
Related
CSS Modules
File structure, naming, and scoping rules.
Responsive design
Breakpoint reference and mobile-first patterns.