| name | tailwindcss |
| description | Utility-first CSS with responsive design. Trigger: When styling with Tailwind utilities, creating responsive designs, or configuring Tailwind. |
| license | Apache 2.0 |
| metadata | {"version":"1.1","type":"tooling","skills":["a11y"],"dependencies":{"tailwindcss":">=3.0.0 <5.0.0"}} |
Tailwind CSS
Utility-first CSS for responsive UIs with composable classes and configuration.
When to Use
Use when:
- Styling with utility-first CSS
- Responsive designs with breakpoints
- Theme config (colors, spacing, typography)
- Custom utilities/plugins
Don't use for: MUI (use mui skill), plain CSS (use css skill), complex animations (use css skill).
Critical Patterns
โ
REQUIRED: Use Utility Classes
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
Click Me
</button>
<button class="custom-button">Click Me</button>
<style>.custom-button { background: blue; padding: 8px 16px; }</style>
โ
REQUIRED: Configure Theme (Tailwind 3)
module.exports = {
theme: {
extend: {
colors: { brand: '#1976d2' },
},
},
};
โ
REQUIRED: Define Themes with @theme (Tailwind 4+)
@theme {
--color-primary: #4f46e5;
--color-secondary: #9333ea;
--font-sans: "Inter", sans-serif;
--radius-md: 0.375rem;
}
โ NEVER: @apply Overuse
.btn {
@apply bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded;
}
โ
REQUIRED: @apply for Shared Component Patterns Only
.card-base {
@apply rounded-lg shadow-md p-6 bg-white;
}
Conventions
Token Hierarchy
Three layers:
1. Brand: Raw OKLCH (--color-brand-blue: oklch(45% 0.2 260))
2. Semantic: Purpose names (--color-primary, --color-destructive)
3. Component: Implementations (.btn-primary { @apply bg-primary; })
See design-system.md for token architecture, CVA patterns, dark mode.
Tailwind v4
CSS-first config with @theme blocks and OKLCH.
Changes: @import 'tailwindcss' replaces @tailwind; @theme replaces config; @custom-variant dark replaces darkMode: "class"
New: size-* shorthand, improved spacing, tree-shakeable animations
See tailwind-v4.md for migration, breaking changes, OKLCH syntax.
Decision Tree
Building a design system?
โ See design-system.md for token hierarchy, semantic naming, CVA patterns
Migrating to Tailwind v4?
โ See tailwind-v4.md for migration checklist, breaking changes, new utilities
Component with variants (size/color/state)?
โ Use CVA (Class Variance Authority) from design-system.md
Tailwind class exists?
โ Use utility class directly (e.g. bg-blue-500)
Dynamic value?
โ Inline style for computed values or arbitrary class (e.g. w-[137px])
Conditional styles?
โ Use clsx/cn: cn("base", condition && "variant")
Reusable component style?
โ Create component with utilities; avoid @apply
Custom color/spacing?
โ Add to theme.extend in config (v3) or @theme block (v4+)
Responsive?
โ Breakpoint prefixes: md:flex lg:grid
Dark mode?
โ v3: Enable in config. v4: Use @custom-variant dark (see tailwind-v4.md)
Production build?
โ Ensure all template paths in content array or classes get purged
Custom animations?
โ v3: Extend theme.animation. v4: Use @keyframes in @theme (see tailwind-v4.md)
Example
<div class="max-w-4xl mx-auto p-6">
<h1 class="text-3xl font-bold text-gray-900 mb-4">Title</h1>
<button
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:ring-2 focus:ring-blue-500"
>
Click Me
</button>
</div>
module.exports = {
content: ["./src/**/*.{astro,html,js,jsx,ts,tsx,vue,svelte}"],
darkMode: "class",
theme: {
extend: { colors: { brand: "#1976d2" } },
},
};
Dark Mode
<html class="dark">
<div class="bg-white dark:bg-gray-900 text-black dark:text-white">
Content adapts to dark mode
</div>
</html>
Edge Cases
- Arbitrary values:
w-[137px] โ avoid; extend theme
- Specificity: Utilities same specificity; HTML order matters; use
! sparingly
- Purge config: All paths in
content or classes removed in prod
- Third-party: Inline styles override; use
!important or wrappers
- @layer:
@layer components for components, @layer utilities for custom
Checklist
Resources