Tailwind CSS Patterns

Tailwind patterns

by davila7 · MIT license · ★ 32,299 on GitHub

Tailwind patterns cover

Tailwind CSS v4 principles. CSS-first configuration, container queries, modern patterns, design token architecture.

---
name: tailwind-patterns
description: Tailwind CSS v4 principles. CSS-first configuration, container queries, modern patterns, design token architecture.
allowed-tools: Read, Write, Edit, Glob, Grep
---

# Tailwind CSS Patterns (v4 - 2025)

> Modern utility-first CSS with CSS-native configuration.

---

## 1. Tailwind v4 Architecture

### What Changed from v3

| v3 (Legacy) | v4 (Current) |
|-------------|--------------|

Overview

Tailwind CSS v4 principles. CSS-first configuration, container queries, modern patterns, design token architecture.

Manual install (npx, ZIP)
Claude Codenpx skills add davila7/claude-code-templates --skill tailwind-patterns -g -a claude-code
Claude Code (degit)npx degit davila7/claude-code-templates/cli-tool/components/skills/creative-design/tailwind-patterns#main ~/.claude/skills/tailwind-patterns
Claude.ai / desktopZip the folder and upload it under Settings → Capabilities → Skills.
Codex, Cursor, other agentsPoint them at SKILL.md. The other files are plain text.

Connects with Agent Alley MCP · agentalley.io/mcp

Files included

  • SKILL.md6.6 KB
Read SKILL.md here
davila7/main1 file shown
SKILL.md
Show the full text270 lines

Tailwind CSS Patterns (v4 - 2025)

Modern utility-first CSS with CSS-native configuration.


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
  1. Write mobile styles first (no prefix)
  2. Add larger screen overrides with prefixes
  3. 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.

1---
2name: tailwind-patterns
3description: Tailwind CSS v4 principles. CSS-first configuration, container queries, modern patterns, design token architecture.
4allowed-tools: Read, Write, Edit, Glob, Grep
5---
6 
7# Tailwind CSS Patterns (v4 - 2025)
8 
9> Modern utility-first CSS with CSS-native configuration.
10 
11---
12 
13## 1. Tailwind v4 Architecture
14 
15### What Changed from v3
16 
17| v3 (Legacy) | v4 (Current) |
18|-------------|--------------|
19| `tailwind.config.js` | CSS-based `@theme` directive |
20| PostCSS plugin | Oxide engine (10x faster) |
21| JIT mode | Native, always-on |
22| Plugin system | CSS-native features |
23| `@apply` directive | Still works, discouraged |
24 
25### v4 Core Concepts
26 
27| Concept | Description |
28|---------|-------------|
29| **CSS-first** | Configuration in CSS, not JavaScript |
30| **Oxide Engine** | Rust-based compiler, much faster |
31| **Native Nesting** | CSS nesting without PostCSS |
32| **CSS Variables** | All tokens exposed as `--*` vars |
33 
34---
35 
36## 2. CSS-Based Configuration
37 
38### Theme Definition
39 
40```
41@theme {
42 /* Colors - use semantic names */
43 --color-primary: oklch(0.7 0.15 250);
44 --color-surface: oklch(0.98 0 0);
45 --color-surface-dark: oklch(0.15 0 0);
46 
47 /* Spacing scale */
48 --spacing-xs: 0.25rem;
49 --spacing-sm: 0.5rem;
50 --spacing-md: 1rem;
51 --spacing-lg: 2rem;
52 
53 /* Typography */
54 --font-sans: 'Inter', system-ui, sans-serif;
55 --font-mono: 'JetBrains Mono', monospace;
56}
57```
58 
59### When to Extend vs Override
60 
61| Action | Use When |
62|--------|----------|
63| **Extend** | Adding new values alongside defaults |
64| **Override** | Replacing default scale entirely |
65| **Semantic tokens** | Project-specific naming (primary, surface) |
66 
67---
68 
69## 3. Container Queries (v4 Native)
70 
71### Breakpoint vs Container
72 
73| Type | Responds To |
74|------|-------------|
75| **Breakpoint** (`md:`) | Viewport width |
76| **Container** (`@container`) | Parent element width |
77 
78### Container Query Usage
79 
80| Pattern | Classes |
81|---------|---------|
82| Define container | `@container` on parent |
83| Container breakpoint | `@sm:`, `@md:`, `@lg:` on children |
84| Named containers | `@container/card` for specificity |
85 
86### When to Use
87 
88| Scenario | Use |
89|----------|-----|
90| Page-level layouts | Viewport breakpoints |
91| Component-level responsive | Container queries |
92| Reusable components | Container queries (context-independent) |
93 
94---
95 
96## 4. Responsive Design
97 
98### Breakpoint System
99 
100| Prefix | Min Width | Target |
101|--------|-----------|--------|
102| (none) | 0px | Mobile-first base |
103| `sm:` | 640px | Large phone / small tablet |
104| `md:` | 768px | Tablet |
105| `lg:` | 1024px | Laptop |
106| `xl:` | 1280px | Desktop |
107| `2xl:` | 1536px | Large desktop |
108 
109### Mobile-First Principle
110 
1111. Write mobile styles first (no prefix)
1122. Add larger screen overrides with prefixes
1133. Example: `w-full md:w-1/2 lg:w-1/3`
114 
115---
116 
117## 5. Dark Mode
118 
119### Configuration Strategies
120 
121| Method | Behavior | Use When |
122|--------|----------|----------|
123| `class` | `.dark` class toggles | Manual theme switcher |
124| `media` | Follows system preference | No user control |
125| `selector` | Custom selector (v4) | Complex theming |
126 
127### Dark Mode Pattern
128 
129| Element | Light | Dark |
130|---------|-------|------|
131| Background | `bg-white` | `dark:bg-zinc-900` |
132| Text | `text-zinc-900` | `dark:text-zinc-100` |
133| Borders | `border-zinc-200` | `dark:border-zinc-700` |
134 
135---
136 
137## 6. Modern Layout Patterns
138 
139### Flexbox Patterns
140 
141| Pattern | Classes |
142|---------|---------|
143| Center (both axes) | `flex items-center justify-center` |
144| Vertical stack | `flex flex-col gap-4` |
145| Horizontal row | `flex gap-4` |
146| Space between | `flex justify-between items-center` |
147| Wrap grid | `flex flex-wrap gap-4` |
148 
149### Grid Patterns
150 
151| Pattern | Classes |
152|---------|---------|
153| Auto-fit responsive | `grid grid-cols-[repeat(auto-fit,minmax(250px,1fr))]` |
154| Asymmetric (Bento) | `grid grid-cols-3 grid-rows-2` with spans |
155| Sidebar layout | `grid grid-cols-[auto_1fr]` |
156 
157> **Note:** Prefer asymmetric/Bento layouts over symmetric 3-column grids.
158 
159---
160 
161## 7. Modern Color System
162 
163### OKLCH vs RGB/HSL
164 
165| Format | Advantage |
166|--------|-----------|
167| **OKLCH** | Perceptually uniform, better for design |
168| **HSL** | Intuitive hue/saturation |
169| **RGB** | Legacy compatibility |
170 
171### Color Token Architecture
172 
173| Layer | Example | Purpose |
174|-------|---------|---------|
175| **Primitive** | `--blue-500` | Raw color values |
176| **Semantic** | `--color-primary` | Purpose-based naming |
177| **Component** | `--button-bg` | Component-specific |
178 
179---
180 
181## 8. Typography System
182 
183### Font Stack Pattern
184 
185| Type | Recommended |
186|------|-------------|
187| Sans | `'Inter', 'SF Pro', system-ui, sans-serif` |
188| Mono | `'JetBrains Mono', 'Fira Code', monospace` |
189| Display | `'Outfit', 'Poppins', sans-serif` |
190 
191### Type Scale
192 
193| Class | Size | Use |
194|-------|------|-----|
195| `text-xs` | 0.75rem | Labels, captions |
196| `text-sm` | 0.875rem | Secondary text |
197| `text-base` | 1rem | Body text |
198| `text-lg` | 1.125rem | Lead text |
199| `text-xl`+ | 1.25rem+ | Headings |
200 
201---
202 
203## 9. Animation & Transitions
204 
205### Built-in Animations
206 
207| Class | Effect |
208|-------|--------|
209| `animate-spin` | Continuous rotation |
210| `animate-ping` | Attention pulse |
211| `animate-pulse` | Subtle opacity pulse |
212| `animate-bounce` | Bouncing effect |
213 
214### Transition Patterns
215 
216| Pattern | Classes |
217|---------|---------|
218| All properties | `transition-all duration-200` |
219| Specific | `transition-colors duration-150` |
220| With easing | `ease-out` or `ease-in-out` |
221| Hover effect | `hover:scale-105 transition-transform` |
222 
223---
224 
225## 10. Component Extraction
226 
227### When to Extract
228 
229| Signal | Action |
230|--------|--------|
231| Same class combo 3+ times | Extract component |
232| Complex state variants | Extract component |
233| Design system element | Extract + document |
234 
235### Extraction Methods
236 
237| Method | Use When |
238|--------|----------|
239| **React/Vue component** | Dynamic, JS needed |
240| **@apply in CSS** | Static, no JS needed |
241| **Design tokens** | Reusable values |
242 
243---
244 
245## 11. Anti-Patterns
246 
247| Don't | Do |
248|-------|-----|
249| Arbitrary values everywhere | Use design system scale |
250| `!important` | Fix specificity properly |
251| Inline `style=` | Use utilities |
252| Duplicate long class lists | Extract component |
253| Mix v3 config with v4 | Migrate fully to CSS-first |
254| Use `@apply` heavily | Prefer components |
255 
256---
257 
258## 12. Performance Principles
259 
260| Principle | Implementation |
261|-----------|----------------|
262| **Purge unused** | Automatic in v4 |
263| **Avoid dynamism** | No template string classes |
264| **Use Oxide** | Default in v4, 10x faster |
265| **Cache builds** | CI/CD caching |
266 
267---
268 
269> **Remember:** Tailwind v4 is CSS-first. Embrace CSS variables, container queries, and native features. The config file is now optional.
270 
View all files on GitHub →

Details

License
MIT
Stars on the repo
★ 32,299
Checked
Source
davila7/claude-code-templates ↗
Creator
davila7 · 212 listings
View creator

Similar skills

See all →
SkillMotion Effect Glossaryemilkowalski/skills · by emilkowalskiReverse-lookup glossary that turns a vague description of a web animation or motion effect into its exact term ("the bouncy thing when a popover opens" → Pop in; "the iOS rubber-band scroll" → Rubber-banding). Use when the user asks "what's it called when…", or describes a motion effect without knowing its name and wants the right word to prompt an AI or designer with. For naming an effect, not designing or building one.★ 40.8k GitHub starsSkillWatercolor Animation Generatoredenfunf/reelmimic · by edenfunfMake hand-painted watercolour-and-ink cartoon videos (MP4) with code — p5.js + p5.brush rendered frame by frame in headless Chrome, encoded with ffmpeg — starring Clawd or any character. Use when the user asks to make an animation, animated short, cartoon, music video, lyric video, animated GIF/loop or "a video of Clawd…", or mentions the PDoomVideo / ClaudeAnimationBase approach. Covers storyboarding, the engine API, the render-and-look review loop, music/lyric sync and splitting long videos across subagents.★ 3.6k GitHub starsSkillModern Web ReferenceGoogleChrome/modern-web-guidance · by GoogleChromeSearch tool for modern web development best practices. MANDATORY: Execute FIRST for all HTML/CSS and clientside JS tasks. Do NOT skip — web APIs evolve rapidly and training weights contain obsolete patterns. Trigger immediately for: - UI/Layout: Modals, dialogs, popovers, Glassmorphism/backdrop-filters, anchor positioning, container queries, `:has()`, `:user-valid`. - Scroll/Motion: View Transitions, Scroll-driven animations, scroll parallax/reveals. - Performance: CWV (LCP, INP), content-visibility, Fetch Priority, image optimization. - System/APIs: Local filesystem access, WebUSB, WebSockets sync, WebAssembly widgets. - Frameworks: Adapting layout/styles in React, Vue, Angular. - General Frontend: Forms, autofill, advanced inputs, custom scrollbars, modern component states, etc. DO NOT trigger for: - Backend: Database SQL, ORMs, Express API routes. - Pipelines: CI/CD deployment, Docker, Actions. - Generic: Local scripts (Python/Go tools), ESLint, Git.★ 2.4k GitHub starsSkillMotion Graphics Translatorapenasdouglas/ai-motion-library · by apenasdouglasTraduz pedidos de animação em português ("faz o número quicar", "entra um depois do outro", "dá um tranco no zoom") para o efeito de motion graphics certo, com o termo técnico, a duração e a aceleração. Use sempre que o usuário pedir animação, motion, transição ou efeito em vídeo, HTML, CSS, GSAP, Remotion, HyperFrames ou After Effects, principalmente quando o pedido for vago ("faz uma animação bonita") ou o vídeo for de canal dark (faceless) de curiosidades, história ou documentário. Also triggers on English requests for motion graphics, easing and animation effects in documentary or faceless YouTube videos.★ 68 GitHub starsSkillBrowser Automation ToolAndyShiu/claude-skill-playwright-browser · by AndyShiuHeadless, reproducible browser automation with Playwright for any project — screenshots of web pages or local dev servers (desktop/tablet/mobile, full page or one element, single page or every page/menu of an app in one batch), frontend audits (console errors, failed requests, broken images/links, responsive overflow, axe accessibility, LCP/CLS performance), before/after visual comparison, scripted E2E flows (log in, click, fill, page through, assert), and logged-in pages via saved sessions. Use this whenever the user wants to screenshot or visually check a site, find frontend bugs, see how a page looks on mobile, compare the UI before and after a CSS/code change, reproduce a bug from an issue or ticket and capture evidence images for it, verify a UI flow works, or run/write a browser test — even if they never say "Playwright" or "browser". If Claude in Chrome could also do the job, briefly ask which to use (with a recommendation) instead of silently picking.★ 49 GitHub starsSkillComponent Rebuilderalbertirgi/replica · by albertirgiRebuild a web page, section, component or interaction from a reference (a live URL, a local HTML file, a screenshot or design export, or a screen recording or GIF) inside the user's own codebase. Then measure the rebuild against the reference (element boxes, computed styles, pixels, motion timing and easing) and iterate until a numeric Replica Score passes. Use when the user wants to clone, replicate, recreate, copy, port or match a site, landing page, hero, navbar, pricing table, card, modal, footer, hover effect, scroll reveal, page-load animation or any other UI, or to "make it look/feel/move like" one. Also use when they say "pixel-perfect", "1:1", "exactly like this" or "same as <url>", or hand over a screenshot, Figma export or video and ask to build it, including when they want their own copy, brand or extra features on top.★ 43 GitHub stars

More from davila7

Skill2D Game Developmentdavila7/claude-code-templates · by davila72D game development principles. Sprites, tilemaps, physics, camera.★ 32.3k GitHub starsSkill3D Game Development Principlesdavila7/claude-code-templates · by davila73D game development principles. Rendering, shaders, physics, cameras.★ 32.3k GitHub starsSkill3D Web Experience Builderdavila7/claude-code-templates · by davila7Expert in building 3D experiences for the web - Three.js, React Three Fiber, Spline, WebGL, and interactive 3D scenes. Covers product configurators, 3D portfolios, immersive websites, and bringing depth to web experiences. Use when: 3D website, three.js, WebGL, react three fiber, 3D experience.★ 32.3k GitHub starsSkillSplit Test Setupdavila7/claude-code-templates · by davila7When the user wants to plan, design, or implement an A/B test or experiment. Also use when the user mentions "A/B test," "split test," "experiment," "test this change," "variant copy," "multivariate test," or "hypothesis." For tracking implementation, see analytics-tracking.★ 32.3k GitHub starsAgentResearch Literature Synthesizerdavila7/claude-code-templates · by davila7Academic research synthesis specialist. Use PROACTIVELY for comprehensive research on academic topics, literature reviews, technical investigations, and well-cited analysis combining multiple sources. <example>Context: A podcast episode needs a segment grounded in peer-reviewed evidence with formal citations. user: "Research the current state of transformer efficiency techniques for the episode, with proper academic citations." assistant: "I'll use the academic-research-synthesizer agent to search arXiv and Semantic Scholar, extract full-text findings via WebFetch, and produce a cited literature synthesis with confidence levels." <commentary>Use academic-research-synthesizer (not comprehensive-researcher) when the episode segment needs peer-reviewed sourcing, formal citation format, and explicit confidence tagging rather than general-purpose multi-source coverage.</commentary></example> <example>Context: The episode-orchestrator has routed a "literature review" request for a technical deep-dive segment. user: "Summarize the research landscape on federated learning privacy guarantees." assistant: "I'll invoke academic-research-synthesizer to systematically search academic sources, note peer-review status per source, and synthesize consensus vs. open debates."</example>★ 32.3k GitHub starsAgentAcademic Research Specialistdavila7/claude-code-templates · by davila7Academic research specialist for scholarly sources, peer-reviewed papers, and academic literature. Use PROACTIVELY for research paper analysis, literature reviews, citation tracking, and academic methodology evaluation. <example>Context: The research-orchestrator has kicked off Phase 4 parallel research on 'efficacy of intermittent fasting' and needs peer-reviewed evidence. user: "Find the academic evidence on intermittent fasting outcomes." assistant: "I'll use the academic-researcher agent to search Semantic Scholar, PubMed, and OpenAlex for peer-reviewed studies and write structured findings to academic-research.md." <commentary>The request is specifically for scholarly/peer-reviewed evidence rather than general web coverage or code, so academic-researcher (not web-researcher or technical-researcher) is the right specialist.</commentary></example> <example>Context: The user wants a literature review comparing methodologies across studies on a topic. user: "Can you review the literature on transformer model interpretability and identify research gaps?" assistant: "Let me invoke the academic-researcher agent to pull foundational and recent papers, extract methodologies, and surface open research gaps." <commentary>Literature review, methodology extraction, and research-gap identification are core academic-researcher capabilities, distinct from technical-researcher's focus on code repositories and implementations.</commentary></example>★ 32.3k GitHub stars