--- name: tailwind-css user-invocable: false description: This skill should be used when the user asks to style with Tailwind v4, add or fix Tailwind classes, use tailwind-variants or tw-animate-css, or configure Tailwind. Trigger phrases include "style with Tailwind", "fix Tailwind styles", "configure Tailwind v4", "migrate to Tailwind v4". --- # Tailwind CSS v4 Expert guidance for Tailwind CSS v4, CSS-first configuration, modern utility patterns, and type-safe component styling with tailwind-variants. ## CSS-First Configuration Tailwind CSS v4 eliminates `tailwind.config.ts` in favor of CSS-only configuration. All configuration lives in CSS files using special directives. **Core Directives:** - `@import "tailwindcss"` - Entry point that loads Tailwind - `@theme { }` - Define or extend design tokens - `@theme static { }` - Define tokens that should not generate utilities - `@utility` - Create custom utilities - `@custom-variant` - Define custom variants **Minimal Example:** ```css @import "tailwindcss"; @theme { --color-brand: oklch(0.72 0.11 178); --font-display: "Inter", sans-serif; --spacing-edge: 1.5rem; } ``` All theme tokens defined with `@theme` automatically become available as utility classes. For example, `--color-brand` can be used as `bg-brand`, `text-brand`, `border-brand`, etc. ## ESLint Integration Use `eslint-plugin-better-tailwindcss` for Tailwind CSS v4 class validation and style enforcement. **Correctness Rules (errors):** - `no-conflicting-classes` - Detect classes that override each other - `no-unknown-classes` - Flag classes not registered with Tailwind **Stylistic Rules (warnings):** - `enforce-canonical-classes` - Use standard v4 class names - `enforce-shorthand-classes` - Use abbreviated class versions - `no-deprecated-classes` - Remove outdated class names - `no-duplicate-classes` - Eliminate redundant declarations - `no-unnecessary-whitespace` - Clean up extra spacing **Examples:** ```typescript // ❌ Bad: separate padding