Tailwind CSS Patterns (v4 - 2025)
Modern utility-first CSS with CSS-native configuration.
When to Use
Use this skill when configuring Tailwind v4, using CSS-first theme and design tokens, or implementing container queries and modern Tailwind patterns.
1. Tailwind v4 Architecture
What Changed from v3
| v3 (Legacy) |
v4 (Current) |
tailwind.config.js |
CSS-based @theme directive |
| PostCSS plugin |
Oxide engine (10x faster) |
| JIT mode |
Native, always-on |
| Plugin system |
CSS-native features |
@apply directive |
Still works, discouraged |
v4 Core Concepts
| 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 --* vars |
2. CSS-Based Configuration
Theme Definition
@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;
}
When to Extend vs Override
| Action |
Use When |
| Extend |
Adding new values alongside defaults |
| Override |
Replacing default scale entirely |
| Semantic tokens |
Project-specific naming (primary, surface) |
3. Container Queries (v4 Native)
Breakpoint vs Container
| Type |
Responds To |
Breakpoint (md:) |
Viewport width |
Container (@container) |
Parent element width |
Container Query Usage
| Pattern |
Classes |
| Define container |
@container on parent |
| Container breakpoint |
@sm:, @md:, @lg: on children |
| Named containers |
@container/card for specificity |
When to Use
| Scenario |
Use |
| Page-level layouts |
Viewport breakpoints |
| Component-level responsive |
Container queries |
| Reusable components |
Container queries (context-independent) |
4. Responsive Design
Breakpoint System
| Prefix |
Min Width |
Target |
| (none) |
0px |
Mobile-first base |
sm: |
640px |
Large phone / small tablet |
md: |
768px |
Tablet |
lg: |
1024px |
Laptop |
xl: |
1280px |
Desktop |
2xl: |
1536px |
Large desktop |
Mobile-First Principle
- Write mobile styles first (no prefix)
- Add larger screen overrides with prefixes
- Example:
w-full md:w-1/2 lg:w-1/3
5. Dark Mode
Configuration Strategies
| Method |
Behavior |
Use When |
class |
.dark class toggles |
Manual theme switcher |
media |
Follows system preference |
No user control |
selector |
Custom selector (v4) |
Complex theming |
Dark Mode Pattern
| Element |
Light |
Dark |
| Background |
bg-white |
dark:bg-zinc-900 |
| Text |
text-zinc-900 |
dark:text-zinc-100 |
| Borders |
border-zinc-200 |
dark:border-zinc-700 |
6. Modern Layout Patterns
Flexbox Patterns
| Pattern |
Classes |
| Center (both axes) |
flex items-center justify-center |
| Vertical stack |
flex flex-col gap-4 |
| Horizontal row |
flex gap-4 |
| Space between |
flex justify-between items-center |
| Wrap grid |
flex flex-wrap gap-4 |
Grid Patterns
| Pattern |
Classes |
| Auto-fit responsive |
grid grid-cols-[repeat(auto-fit,minmax(250px,1fr))] |
| Asymmetric (Bento) |
grid grid-cols-3 grid-rows-2 with spans |
| Sidebar layout |
grid grid-cols-[auto_1fr] |
Note: Prefer asymmetric/Bento layouts over symmetric 3-column grids.
7. Modern Color System
OKLCH vs RGB/HSL
| Format |
Advantage |
| OKLCH |
Perceptually uniform, better for design |
| HSL |
Intuitive hue/saturation |
| RGB |
Legacy compatibility |
Color Token Architecture
| Layer |
Example |
Purpose |
| Primitive |
--blue-500 |
Raw color values |
| Semantic |
--color-primary |
Purpose-based naming |
| Component |
--button-bg |
Component-specific |
8. Typography System
Font Stack Pattern
| Type |
Recommended |
| Sans |
'Inter', 'SF Pro', system-ui, sans-serif |
| Mono |
'JetBrains Mono', 'Fira Code', monospace |
| Display |
'Outfit', 'Poppins', sans-serif |
Type Scale
| Class |
Size |
Use |
text-xs |
0.75rem |
Labels, captions |
text-sm |
0.875rem |
Secondary text |
text-base |
1rem |
Body text |
text-lg |
1.125rem |
Lead text |
text-xl+ |
1.25rem+ |
Headings |
9. Animation & Transitions
Built-in Animations
| Class |
Effect |
animate-spin |
Continuous rotation |
animate-ping |
Attention pulse |
animate-pulse |
Subtle opacity pulse |
animate-bounce |
Bouncing effect |
Transition Patterns
| Pattern |
Classes |
| All properties |
transition-all duration-200 |
| Specific |
transition-colors duration-150 |
| With easing |
ease-out or ease-in-out |
| Hover effect |
hover:scale-105 transition-transform |
10. Component Extraction
When to Extract
| Signal |
Action |
| Same class combo 3+ times |
Extract component |
| Complex state variants |
Extract component |
| Design system element |
Extract + document |
Extraction Methods
| Method |
Use When |
| React/Vue component |
Dynamic, JS needed |
| @apply in CSS |
Static, no JS needed |
| Design tokens |
Reusable values |
11. Anti-Patterns
| Don't |
Do |
| Arbitrary values everywhere |
Use design system scale |
!important |
Fix specificity properly |
Inline style= |
Use utilities |
| Duplicate long class lists |
Extract component |
| Mix v3 config with v4 |
Migrate fully to CSS-first |
Use @apply heavily |
Prefer components |
12. Performance Principles
| 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.
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
Source: sickn33/agentic-awesome-skills → skills/tailwind-patterns/SKILL.md
Also appears in: sickn33/agentic-awesome-skills/plugins/agentic-awesome-skills/skills/tailwind-patterns/SKILL.md, sickn33/agentic-awesome-skills/plugins/agentic-bundle-web-wizard/skills/tailwind-patterns/SKILL.md, sickn33/agentic-awesome-skills/plugins/agentic-awesome-skills-claude/skills/tailwind-patterns/SKILL.md, sickn33/agentic-awesome-skills/plugins/agentic-bundle-aas-web-app-builder/skills/tailwind-patterns/SKILL.md
1---2name: tailwind-patterns3description: Tailwind CSS v4 principles. CSS-first configuration, container queries, modern patterns, design token architecture.4---567# Tailwind CSS Patterns (v4 - 2025)89> Modern utility-first CSS with CSS-native configuration.1011## When to Use12Use this skill when configuring Tailwind v4, using CSS-first theme and design tokens, or implementing container queries and modern Tailwind patterns.1314---1516## 1. Tailwind v4 Architecture1718### What Changed from v31920| v3 (Legacy) | v4 (Current) |21|-------------|--------------|22| `tailwind.config.js` | CSS-based `@theme` directive |23| PostCSS plugin | Oxide engine (10x faster) |24| JIT mode | Native, always-on |25| Plugin system | CSS-native features |26| `@apply` directive | Still works, discouraged |2728### v4 Core Concepts2930| Concept | Description |31|---------|-------------|32| **CSS-first** | Configuration in CSS, not JavaScript |33| **Oxide Engine** | Rust-based compiler, much faster |34| **Native Nesting** | CSS nesting without PostCSS |35| **CSS Variables** | All tokens exposed as `--*` vars |3637---3839## 2. CSS-Based Configuration4041### Theme Definition4243```44@theme {45 /* Colors - use semantic names */46 --color-primary: oklch(0.7 0.15 250);47 --color-surface: oklch(0.98 0 0);48 --color-surface-dark: oklch(0.15 0 0);49 50 /* Spacing scale */51 --spacing-xs: 0.25rem;52 --spacing-sm: 0.5rem;53 --spacing-md: 1rem;54 --spacing-lg: 2rem;55 56 /* Typography */57 --font-sans: 'Inter', system-ui, sans-serif;58 --font-mono: 'JetBrains Mono', monospace;59}60```6162### When to Extend vs Override6364| Action | Use When |65|--------|----------|66| **Extend** | Adding new values alongside defaults |67| **Override** | Replacing default scale entirely |68| **Semantic tokens** | Project-specific naming (primary, surface) |6970---7172## 3. Container Queries (v4 Native)7374### Breakpoint vs Container7576| Type | Responds To |77|------|-------------|78| **Breakpoint** (`md:`) | Viewport width |79| **Container** (`@container`) | Parent element width |8081### Container Query Usage8283| Pattern | Classes |84|---------|---------|85| Define container | `@container` on parent |86| Container breakpoint | `@sm:`, `@md:`, `@lg:` on children |87| Named containers | `@container/card` for specificity |8889### When to Use9091| Scenario | Use |92|----------|-----|93| Page-level layouts | Viewport breakpoints |94| Component-level responsive | Container queries |95| Reusable components | Container queries (context-independent) |9697---9899## 4. Responsive Design100101### Breakpoint System102103| Prefix | Min Width | Target |104|--------|-----------|--------|105| (none) | 0px | Mobile-first base |106| `sm:` | 640px | Large phone / small tablet |107| `md:` | 768px | Tablet |108| `lg:` | 1024px | Laptop |109| `xl:` | 1280px | Desktop |110| `2xl:` | 1536px | Large desktop |111112### Mobile-First Principle1131141. Write mobile styles first (no prefix)1152. Add larger screen overrides with prefixes1163. Example: `w-full md:w-1/2 lg:w-1/3`117118---119120## 5. Dark Mode121122### Configuration Strategies123124| Method | Behavior | Use When |125|--------|----------|----------|126| `class` | `.dark` class toggles | Manual theme switcher |127| `media` | Follows system preference | No user control |128| `selector` | Custom selector (v4) | Complex theming |129130### Dark Mode Pattern131132| Element | Light | Dark |133|---------|-------|------|134| Background | `bg-white` | `dark:bg-zinc-900` |135| Text | `text-zinc-900` | `dark:text-zinc-100` |136| Borders | `border-zinc-200` | `dark:border-zinc-700` |137138---139140## 6. Modern Layout Patterns141142### Flexbox Patterns143144| Pattern | Classes |145|---------|---------|146| Center (both axes) | `flex items-center justify-center` |147| Vertical stack | `flex flex-col gap-4` |148| Horizontal row | `flex gap-4` |149| Space between | `flex justify-between items-center` |150| Wrap grid | `flex flex-wrap gap-4` |151152### Grid Patterns153154| Pattern | Classes |155|---------|---------|156| Auto-fit responsive | `grid grid-cols-[repeat(auto-fit,minmax(250px,1fr))]` |157| Asymmetric (Bento) | `grid grid-cols-3 grid-rows-2` with spans |158| Sidebar layout | `grid grid-cols-[auto_1fr]` |159160> **Note:** Prefer asymmetric/Bento layouts over symmetric 3-column grids.161162---163164## 7. Modern Color System165166### OKLCH vs RGB/HSL167168| Format | Advantage |169|--------|-----------|170| **OKLCH** | Perceptually uniform, better for design |171| **HSL** | Intuitive hue/saturation |172| **RGB** | Legacy compatibility |173174### Color Token Architecture175176| Layer | Example | Purpose |177|-------|---------|---------|178| **Primitive** | `--blue-500` | Raw color values |179| **Semantic** | `--color-primary` | Purpose-based naming |180| **Component** | `--button-bg` | Component-specific |181182---183184## 8. Typography System185186### Font Stack Pattern187188| Type | Recommended |189|------|-------------|190| Sans | `'Inter', 'SF Pro', system-ui, sans-serif` |191| Mono | `'JetBrains Mono', 'Fira Code', monospace` |192| Display | `'Outfit', 'Poppins', sans-serif` |193194### Type Scale195196| Class | Size | Use |197|-------|------|-----|198| `text-xs` | 0.75rem | Labels, captions |199| `text-sm` | 0.875rem | Secondary text |200| `text-base` | 1rem | Body text |201| `text-lg` | 1.125rem | Lead text |202| `text-xl`+ | 1.25rem+ | Headings |203204---205206## 9. Animation & Transitions207208### Built-in Animations209210| Class | Effect |211|-------|--------|212| `animate-spin` | Continuous rotation |213| `animate-ping` | Attention pulse |214| `animate-pulse` | Subtle opacity pulse |215| `animate-bounce` | Bouncing effect |216217### Transition Patterns218219| Pattern | Classes |220|---------|---------|221| All properties | `transition-all duration-200` |222| Specific | `transition-colors duration-150` |223| With easing | `ease-out` or `ease-in-out` |224| Hover effect | `hover:scale-105 transition-transform` |225226---227228## 10. Component Extraction229230### When to Extract231232| Signal | Action |233|--------|--------|234| Same class combo 3+ times | Extract component |235| Complex state variants | Extract component |236| Design system element | Extract + document |237238### Extraction Methods239240| Method | Use When |241|--------|----------|242| **React/Vue component** | Dynamic, JS needed |243| **@apply in CSS** | Static, no JS needed |244| **Design tokens** | Reusable values |245246---247248## 11. Anti-Patterns249250| Don't | Do |251|-------|-----|252| Arbitrary values everywhere | Use design system scale |253| `!important` | Fix specificity properly |254| Inline `style=` | Use utilities |255| Duplicate long class lists | Extract component |256| Mix v3 config with v4 | Migrate fully to CSS-first |257| Use `@apply` heavily | Prefer components |258259---260261## 12. Performance Principles262263| Principle | Implementation |264|-----------|----------------|265| **Purge unused** | Automatic in v4 |266| **Avoid dynamism** | No template string classes |267| **Use Oxide** | Default in v4, 10x faster |268| **Cache builds** | CI/CD caching |269270---271272> **Remember:** Tailwind v4 is CSS-first. Embrace CSS variables, container queries, and native features. The config file is now optional.273274## Limitations275- Use this skill only when the task clearly matches the scope described above.276- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.277- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.278279---280281**Source:** [`sickn33/agentic-awesome-skills`](https://github.com/sickn33/agentic-awesome-skills) → `skills/tailwind-patterns/SKILL.md`282283**Also appears in:** `sickn33/agentic-awesome-skills/plugins/agentic-awesome-skills/skills/tailwind-patterns/SKILL.md`, `sickn33/agentic-awesome-skills/plugins/agentic-bundle-web-wizard/skills/tailwind-patterns/SKILL.md`, `sickn33/agentic-awesome-skills/plugins/agentic-awesome-skills-claude/skills/tailwind-patterns/SKILL.md`, `sickn33/agentic-awesome-skills/plugins/agentic-bundle-aas-web-app-builder/skills/tailwind-patterns/SKILL.md`