Loading...
Loading...
Tailwind CSS v4 principles. CSS-first configuration, container queries, modern patterns, design token architecture.
npx skill4agent add liuchiawei/agent-skills tailwind-patternsModern utility-first CSS with CSS-native configuration.
| v3 (Legacy) | v4 (Current) |
|---|---|
| CSS-based |
| PostCSS plugin | Oxide engine (10x faster) |
| JIT mode | Native, always-on |
| Plugin system | CSS-native features |
| Still works, discouraged |
| Concept | Description |
|---|---|
| CSS-first | Configuration in CSS, not JavaScript |
| Oxide Engine | Rust-based compiler, much faster |
| Native Nesting | CSS nesting without PostCSS |
| CSS Variables | All tokens exposed as |
@theme {
/* Colors - use semantic names */
--color-primary: oklch(0.7 0.15 250);
--color-surface: oklch(0.98 0 0);
--color-surface-dark: oklch(0.15 0 0);
/* Spacing scale */
--spacing-xs: 0.25rem;
--spacing-sm: 0.5rem;
--spacing-md: 1rem;
--spacing-lg: 2rem;
/* Typography */
--font-sans: 'Inter', system-ui, sans-serif;
--font-mono: 'JetBrains Mono', monospace;
}| Action | Use When |
|---|---|
| Extend | Adding new values alongside defaults |
| Override | Replacing default scale entirely |
| Semantic tokens | Project-specific naming (primary, surface) |
| Type | Responds To |
|---|---|
Breakpoint ( | Viewport width |
Container ( | Parent element width |
| Pattern | Classes |
|---|---|
| Define container | |
| Container breakpoint | |
| Named containers | |
| Scenario | Use |
|---|---|
| Page-level layouts | Viewport breakpoints |
| Component-level responsive | Container queries |
| Reusable components | Container queries (context-independent) |
| Prefix | Min Width | Target |
|---|---|---|
| (none) | 0px | Mobile-first base |
| 640px | Large phone / small tablet |
| 768px | Tablet |
| 1024px | Laptop |
| 1280px | Desktop |
| 1536px | Large desktop |
w-full md:w-1/2 lg:w-1/3| Method | Behavior | Use When |
|---|---|---|
| | Manual theme switcher |
| Follows system preference | No user control |
| Custom selector (v4) | Complex theming |
| Element | Light | Dark |
|---|---|---|
| Background | | |
| Text | | |
| Borders | | |
| Pattern | Classes |
|---|---|
| Center (both axes) | |
| Vertical stack | |
| Horizontal row | |
| Space between | |
| Wrap grid | |
| Pattern | Classes |
|---|---|
| Auto-fit responsive | |
| Asymmetric (Bento) | |
| Sidebar layout | |
Note: Prefer asymmetric/Bento layouts over symmetric 3-column grids.
| Format | Advantage |
|---|---|
| OKLCH | Perceptually uniform, better for design |
| HSL | Intuitive hue/saturation |
| RGB | Legacy compatibility |
| Layer | Example | Purpose |
|---|---|---|
| Primitive | | Raw color values |
| Semantic | | Purpose-based naming |
| Component | | Component-specific |
| Type | Recommended |
|---|---|
| Sans | |
| Mono | |
| Display | |
| Class | Size | Use |
|---|---|---|
| 0.75rem | Labels, captions |
| 0.875rem | Secondary text |
| 1rem | Body text |
| 1.125rem | Lead text |
| 1.25rem+ | Headings |
| Class | Effect |
|---|---|
| Continuous rotation |
| Attention pulse |
| Subtle opacity pulse |
| Bouncing effect |
| Pattern | Classes |
|---|---|
| All properties | |
| Specific | |
| With easing | |
| Hover effect | |
| Signal | Action |
|---|---|
| Same class combo 3+ times | Extract component |
| Complex state variants | Extract component |
| Design system element | Extract + document |
| Method | Use When |
|---|---|
| React/Vue component | Dynamic, JS needed |
| @apply in CSS | Static, no JS needed |
| Design tokens | Reusable values |
| Don't | Do |
|---|---|
| Arbitrary values everywhere | Use design system scale |
| Fix specificity properly |
Inline | Use utilities |
| Duplicate long class lists | Extract component |
| Mix v3 config with v4 | Migrate fully to CSS-first |
Use | Prefer components |
| Principle | Implementation |
|---|---|
| Purge unused | Automatic in v4 |
| Avoid dynamism | No template string classes |
| Use Oxide | Default in v4, 10x faster |
| Cache builds | CI/CD caching |
Remember: Tailwind v4 is CSS-first. Embrace CSS variables, container queries, and native features. The config file is now optional.