---
name: tailwindcss
description: This skill should be used when the user asks to "style with Tailwind", "add CSS", "configure theme", "use @theme", "add custom colors", "implement dark mode", "use container queries", "add responsive design", "use OKLCH colors", or discusses styling, theming, or visual design. Always use the latest Tailwind CSS version and modern patterns.
version: 1.0.0
---
# Tailwind CSS Development
This skill provides guidance for styling applications with Tailwind CSS, focusing on **always using the latest version** and modern patterns.
> **Philosophy:** Use CSS-first configuration with `@theme`. Use OKLCH colors for perceptual uniformity. Prefer `@container` queries over media queries when appropriate.
## Quick Reference
| Feature | Modern Approach | Legacy (Avoid) |
|---------|----------------|----------------|
| Configuration | CSS `@theme` directive | `tailwind.config.js` |
| Colors | OKLCH color space | RGB/HSL colors |
| Container queries | `@container` | Media queries only |
| Content detection | Automatic | Manual `content: []` config |
| PostCSS plugin | `@tailwindcss/postcss` | `tailwindcss` package |
## Installation (Next.js)
```bash
npm install tailwindcss @tailwindcss/postcss postcss
```
```js
// postcss.config.mjs
export default {
plugins: {
'@tailwindcss/postcss': {}
}
}
```
```css
/* app/globals.css */
@import "tailwindcss";
```
## CSS-First Configuration
### The @theme Directive
Define your design system directly in CSS:
```css
@import "tailwindcss";
@theme {
/* Colors */
--color-brand: oklch(0.6 0.15 250);
--color-brand-light: oklch(0.8 0.1 250);
--color-brand-dark: oklch(0.4 0.15 250);
/* Fonts */
--font-display: "Cal Sans", sans-serif;
--font-body: "Inter", system-ui, sans-serif;
/* Spacing */
--spacing-18: 4.5rem;
--spacing-128: 32rem;
/* Border radius */
--radius-xl: 1rem;
--radius-2xl: 1.5rem;
/* Shadows */
--shadow-soft: 0 4px 12px oklch(0 0 0 / 0.08);
/* Animations */
--animate-fade-in: fade-in 0.3s ease-out;
}
@keyframes fade-in {
from { opacity: 0; transform: translateY(-4px); }
to { opacity: 1; transform: translateY(0); }
}
```
Use in HTML:
```html
Styled with custom theme
```
## OKLCH Color System
OKLCH provides perceptually uniform colors:
```css
@theme {
/* Primary palette */
--color-primary-50: oklch(0.98 0.01 250);
--color-primary-100: oklch(0.95 0.03 250);
--color-primary-200: oklch(0.90 0.06 250);
--color-primary-300: oklch(0.82 0.10 250);
--color-primary-400: oklch(0.70 0.14 250);
--color-primary-500: oklch(0.60 0.16 250);
--color-primary-600: oklch(0.50 0.14 250);
--color-primary-700: oklch(0.40 0.12 250);
--color-primary-800: oklch(0.30 0.08 250);
--color-primary-900: oklch(0.20 0.05 250);
--color-primary-950: oklch(0.12 0.03 250);
/* Semantic colors */
--color-success: oklch(0.65 0.15 145);
--color-warning: oklch(0.75 0.15 85);
--color-error: oklch(0.55 0.2 25);
}
```
OKLCH format: `oklch(lightness chroma hue)`
- **Lightness**: 0 (black) to 1 (white)
- **Chroma**: 0 (gray) to ~0.4 (vivid)
- **Hue**: 0-360 degrees (red=25, yellow=85, green=145, blue=250)
## Container Queries
Style based on container size, not viewport:
```html
Content adapts to container
```
### Named Containers
```html
```
### Container Breakpoints
| Modifier | Min Width |
|----------|-----------|
| `@xs` | 20rem (320px) |
| `@sm` | 24rem (384px) |
| `@md` | 28rem (448px) |
| `@lg` | 32rem (512px) |
| `@xl` | 36rem (576px) |
| `@2xl` | 42rem (672px) |
## Dark Mode
### Using CSS Variables
```css
@theme {
/* Light mode (default) */
--color-surface: oklch(0.99 0 0);
--color-surface-elevated: oklch(1 0 0);
--color-text: oklch(0.15 0 0);
--color-text-muted: oklch(0.4 0 0);
/* Dark mode overrides */
@variant dark {
--color-surface: oklch(0.15 0 0);
--color-surface-elevated: oklch(0.2 0 0);
--color-text: oklch(0.95 0 0);
--color-text-muted: oklch(0.7 0 0);
}
}
```
```html
Automatically adapts to dark mode
```
### Class-Based Dark Mode
```html
```
## Responsive Design
### Mobile-First Breakpoints
```html
Responsive element
```
### Breakpoint Reference
| Prefix | Min Width | CSS |
|--------|-----------|-----|
| `sm` | 640px | `@media (min-width: 640px)` |
| `md` | 768px | `@media (min-width: 768px)` |
| `lg` | 1024px | `@media (min-width: 1024px)` |
| `xl` | 1280px | `@media (min-width: 1280px)` |
| `2xl` | 1536px | `@media (min-width: 1536px)` |
## Typography
```html
Heading 1
Heading 2
Heading 3
Regular paragraph
Small muted text
Bold
Italic
Underlined
Strikethrough
```
## Flexbox & Grid
### Flexbox
```html
```
### Grid
```html
```
## States and Variants
```html
```
## Animations
```html
Loading skeleton
Spinner
Bounce
Ping effect
Transform on hover
Respects user preferences
```
## Common Patterns
### Card
```html
Card Title
Card description
```
### Button
```html
```
### Input
```html
```
## Additional Resources
For detailed patterns, see reference files:
- **`references/theme-directive.md`** - Complete @theme configuration
- **`references/colors.md`** - OKLCH color system deep dive