---
name: tailwind-css
user-invocable: false
description: This skill should be used when the user asks to "style with Tailwind", "add Tailwind classes", "fix Tailwind styles", "use tailwind-variants", "add animations with tw-animate-css", "configure Tailwind v4", "migrate to Tailwind v4", or mentions Tailwind utilities, CSS classes, responsive design, dark mode, gradients, design tokens, or CSS Modules.
---
# 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
// ✅ Good: shorthand
```
```typescript
// ❌ Bad: separate width/height
// ✅ Good: size utility
```
Run the project's ESLint check after modifying Tailwind classes to validate all changes across the codebase.
## Coding Preferences
### Layout and Spacing
**Use `gap` for flex/grid spacing, not `space-x`/`space-y`:**
The `gap` utilities handle wrapping correctly, while `space-*` utilities break when flex/grid items wrap to multiple lines.
```typescript
// ✅ Good: gap handles wrapping
// ❌ Bad: breaks when items wrap
```
**Prefer `size-*` over separate `w-*`/`h-*` for equal dimensions:**
```typescript
// ✅ Good: concise
// ❌ Bad: redundant
```
**Always use `min-h-dvh` instead of `min-h-screen`:**
Dynamic viewport height (`dvh`) accounts for mobile browser chrome, while `vh` units ignore it and cause layout issues on mobile Safari.
```typescript
// ✅ Good: works on mobile Safari
// ❌ Bad: buggy on mobile Safari
```
**Prefer top/left margins over bottom/right:**
Consistent directionality improves layout predictability.
```typescript
// ✅ Good: top margin
// ❌ Avoid: bottom margin (unless needed)
```
**Use padding on parent containers instead of bottom margins on last child:**
Padding provides consistent spacing without needing `:last-child` selectors.
```typescript
// ✅ Good: padding on parent
```
### Typography
**Avoid `leading-*` classes; use line height modifiers:**
Tailwind v4 supports inline line height modifiers with the `text-{size}/{leading}` syntax.
```typescript
// ✅ Good: combined size and line height
// ❌ Bad: separate utilities
```
**Font Size Reference:**
| Class | Size |
| ----------- | ---- |
| `text-xs` | 12px |
| `text-sm` | 14px |
| `text-base` | 16px |
| `text-lg` | 18px |
| `text-xl` | 20px |
### Colors and Opacity
**Use opacity modifier syntax, not separate opacity utilities:**
All `*-opacity-*` utilities were removed in Tailwind v4. Use the modifier syntax instead.
```typescript
// ✅ Good: opacity modifier
// ❌ Bad: removed in v4
```
**Prefer design tokens over arbitrary hex values:**
Check the project's `@theme` configuration before using arbitrary color values.
```typescript
// ✅ Good: theme token