--- name: use-tailwind-v4 description: "Tailwind CSS v4 reference and migration guide. Use for v4 projects, syntax changes, upgrading from v3, and troubleshooting v4-specific utility patterns or configuration differences." --- # Tailwind CSS v4 ## v4 Syntax At a Glance ### Imports and Setup ```css /* v4 import (replaces @tailwind directives) */ @import "tailwindcss"; /* Custom utilities (replaces @layer utilities) */ @utility tab-4 { tab-size: 4; } /* Loading JS config (if still needed) */ @config "../../tailwind.config.js"; ``` ### CSS Variables for Theme v4 exposes all theme values as CSS variables. Prefer these over `theme()`: ```css background-color: var(--color-red-500); font-family: var(--font-sans); ``` ## Quick Reference: v3 → v4 Changes ### Renamed Utilities | v3 | v4 | Notes | |----|-----|-------| | `shadow-sm` | `shadow-xs` | Scale shifted | | `shadow` | `shadow-sm` | Scale shifted | | `drop-shadow-sm` | `drop-shadow-xs` | Scale shifted | | `drop-shadow` | `drop-shadow-sm` | Scale shifted | | `blur-sm` | `blur-xs` | Scale shifted | | `blur` | `blur-sm` | Scale shifted | | `backdrop-blur-sm` | `backdrop-blur-xs` | Scale shifted | | `backdrop-blur` | `backdrop-blur-sm` | Scale shifted | | `rounded-sm` | `rounded-xs` | Scale shifted | | `rounded` | `rounded-sm` | Scale shifted | | `outline-none` | `outline-hidden` | `outline-none` now sets `outline-style: none` | | `ring` | `ring-3` | Default changed from 3px to 1px | ### Deprecated Utilities (Use Opacity Modifiers) ```html