---
name: tailwind-patterns
description: |
Production-ready Tailwind CSS patterns for common website components: responsive layouts, cards, navigation, forms, buttons, and typography. Includes spacing scale, breakpoints, mobile-first patterns, and dark mode support.
Use when building UI components, creating landing pages, styling forms, implementing navigation, or fixing responsive layouts.
---
# Tailwind CSS Component Patterns
**Status**: Production Ready ✅
**Last Updated**: 2026-01-14
**Tailwind Compatibility**: v3.x and v4.x
**Source**: Production projects, shadcn/ui patterns
---
## Quick Start
### Essential Patterns
```tsx
// Section Container
// Card Base
```
---
## Container Patterns
### Standard Page Container
```tsx
{/* content */}
```
**Variations**:
- `max-w-4xl` - Narrow content (blog posts)
- `max-w-5xl` - Medium content
- `max-w-6xl` - Wide content
- `max-w-7xl` - Full width (default)
### Section Spacing
```tsx
```
---
## Card Patterns
### Basic Card
```tsx
Card Title
Card description goes here.
```
### Feature Card with Icon
```tsx
{/* Icon */}
Feature Title
Feature description.
```
### Pricing Card
```tsx
Pro Plan
$29/mo
For growing teams
Get Started
```
See `references/card-patterns.md` for more variants.
---
## Grid Layouts
### Auto-Responsive Grid
```tsx
{items.map(item => )}
```
### Auto-Fit Grid (Dynamic Columns)
```tsx
{/* Automatically adjusts columns based on available space */}
```
### Masonry-Style Grid
```tsx
```
---
## Button Patterns
```tsx
// Primary
Primary
// Secondary
Secondary
// Outline
Outline
// Ghost
Ghost
// Destructive
Delete
```
**Size Variants**:
- Small: `px-3 py-1.5 text-sm`
- Default: `px-4 py-2`
- Large: `px-6 py-3 text-lg`
See `references/button-patterns.md` for full reference.
---
## Form Patterns
### Input Field
```tsx
Email
```
### Select Dropdown
```tsx
Option 1
Option 2
```
### Checkbox
```tsx
I agree to the terms
```
### Error State
```tsx
```
See `references/form-patterns.md` for complete patterns.
---
## Typography Patterns
### Headings
```tsx
Page Title
Section Title
Subsection
Card Title
```
### Body Text
```tsx
Regular paragraph text.
Larger body text with comfortable line height.
Small supporting text or captions.
```
### Lists
```tsx
```
See `references/typography-patterns.md` for complete guide.
---
## Navigation Patterns
### Header with Logo
```tsx
```
### Footer
```tsx
```
See `references/navigation-patterns.md` for mobile menus and dropdowns.
---
## Dark Mode Support
All patterns use semantic color tokens that automatically adapt:
| Token | Light Mode | Dark Mode |
|-------|------------|-----------|
| `bg-background` | White | Dark gray |
| `text-foreground` | Dark gray | White |
| `bg-card` | White | Slightly lighter gray |
| `text-muted-foreground` | Gray | Light gray |
| `border-border` | Light gray | Dark gray |
| `bg-primary` | Brand color | Lighter brand color |
**Never use raw colors** like `bg-blue-500` - always use semantic tokens.
See `references/dark-mode-patterns.md` for theme toggle implementation.
---
## Common Class Combinations
### Section with Heading
```tsx
Section Title
{/* content */}
```
### Centered Content
```tsx
Centered Title
Centered description
```
### Hover Effects
```tsx
// Lift on hover
// Shadow on hover
// Color change on hover
```
---
## Critical Rules
### ✅ Always Do
1. Use semantic color tokens (`bg-card`, `text-foreground`)
2. Apply mobile-first responsive design (`base → sm: → md:`)
3. Use consistent spacing scale (4, 6, 8, 12, 16, 24)
4. Add `transition-*` classes for smooth interactions
5. Test in both light and dark modes
### ❌ Never Do
1. Use raw Tailwind colors (`bg-blue-500` breaks themes)
2. Skip responsive prefixes (mobile users suffer)
3. Mix spacing scales randomly (creates visual chaos)
4. Forget hover states on interactive elements
5. Use fixed px values for text (`text-base` not `text-[16px]`)
---
## Template Components
Ready-to-use components in `templates/components/`:
- **hero-section.tsx** - Responsive hero with CTA
- **feature-grid.tsx** - 3-column feature grid with icons
- **contact-form.tsx** - Full form with validation styles
- **footer.tsx** - Multi-column footer with links
Copy and customize for your project.
---
## Reference Documentation
Detailed patterns in `references/` directory:
- **layout-patterns.md** - Containers, grids, flexbox layouts
- **card-patterns.md** - All card variants and states
- **navigation-patterns.md** - Headers, menus, breadcrumbs, footers
- **form-patterns.md** - Complete form styling guide
- **button-patterns.md** - All button variants and sizes
- **typography-patterns.md** - Text styles and hierarchies
- **dark-mode-patterns.md** - Theme switching implementation
---
## Official Documentation
- **Tailwind CSS**: https://tailwindcss.com/docs
- **shadcn/ui**: https://ui.shadcn.com
- **Tailwind UI**: https://tailwindui.com (premium examples)
---
**Last Updated**: 2026-01-14
**Skill Version**: 1.0.0
**Production**: Tested across 10+ projects