---
id: bobmatnyc/claude-mpm-skills/tailwind
version: "29532c5e"
license: MIT
install: manual
updated: 2026-07-18
---
# tailwind โ This skill covers Tailwind CSS, a utility-first framework that lets you compose designs from low-level utility classes instead of writing CSS. Learn responsive design patterns, dark mode implementation, configuration options, and how to integrate Tailwind into modern component frameworks.
Publisher: bobmatnyc ยท Stars: 62 ยท Updated: 2026-07-18
Install (manual): `git clone https://github.com/bobmatnyc/claude-mpm-skills`
## SKILL.md
# Tailwind CSS Skill
---
progressive_disclosure:
entry_point:
- summary
- when_to_use
- quick_start
sections:
core_concepts:
- utility_first_approach
- responsive_design
- configuration
advanced:
- dark_mode
- custom_utilities
- plugins
- performance_optimization
integration:
- framework_integration
- component_patterns
reference:
- common_utilities
- breakpoints
- color_system
tokens:
entry: 75
full: 4500
---
## Summary
Tailwind CSS is a utility-first CSS framework that provides low-level utility classes to build custom designs without writing CSS. It offers responsive design, dark mode, customization through configuration, and integrates seamlessly with modern frameworks.
## When to Use
**Best for:**
- Rapid prototyping with consistent design systems
- Component-based frameworks (React, Vue, Svelte)
- Projects requiring responsive and dark mode support
- Teams wanting to avoid CSS file maintenance
- Design systems with standardized spacing/colors
**Consider alternatives when:**
- Team unfamiliar with utility-first approach (learning curve)
- Project requires extensive custom CSS animations
- Legacy browser support needed (IE11)
- Minimal CSS footprint required without build process
## Quick Start
### Installation
```bash
# npm
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
# yarn
yarn add -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
# pnpm
pnpm add -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
```
### Configuration
**tailwind.config.js:**
```javascript
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./src/**/*.{js,jsx,ts,tsx}",
"./public/index.html",
],
theme: {
extend: {},
},
plugins: [],
}
```
### Basic CSS Setup
**styles/globals.css:**
```css
@tailwind base;
@tailwind components;
@tailwind utilities;
```
### First Component
```jsx
// Simple button with Tailwind utilities
function Button({ children, variant = 'primary' }) {
const baseClasses = "px-4 py-2 rounded-lg font-medium transition-colors";
const variants = {
primary: "bg-blue-600 text-white hover:bg-blue-700",
secondary: "bg-gray-200 text-gray-900 hover:bg-gray-300",
danger: "bg-red-600 text-white hover:bg-red-700"
};
return (
);
}
```
---
## Core Concepts
### Utility-First Approach
Tailwind provides single-purpose utility classes that map directly to CSS properties.
#### Layout Utilities
**Flexbox:**
```jsx
// Centered flex container
// Responsive flex direction
// Flex wrapping and alignment
```
**Grid:**
```jsx
// Basic grid
// Responsive grid
// Auto-fit grid
Auto-sized item
Auto-sized item
```
#### Spacing System
**Padding and Margin:**
```jsx
// Uniform spacing
Padding all sides
Margin all sides
// Directional spacing
Top 4, bottom 8, horizontal 6
Right-aligned with margin
// Negative margins
Overlap bottom
// Responsive spacing
Responsive padding
```
**Space Between:**
```jsx
// Gap between children
// Responsive gap
```
#### Typography
```jsx
// Font sizes and weights
Heading
Paragraph
Caption
// Text alignment and decoration
Centered underlined text
Right-aligned strikethrough
// Responsive typography
Responsive heading
// Text overflow handling
This text will be truncated with ellipsis...
This text will be clamped to 3 lines with ellipsis...
```
#### Colors
```jsx
// Background colors
Blue background
Adaptive background
// Text colors
Red text
Adaptive text
// Border colors
Hover border
// Opacity modifiers
50% opacity blue
25% opacity black
```
### Responsive Design
Tailwind uses mobile-first breakpoint system.
#### Breakpoints
```javascript
// Default breakpoints (tailwind.config.js)
{
theme: {
screens: {
'sm': '640px', // Small devices
'md': '768px', // Medium devices
'lg': '1024px', // Large devices
'xl': '1280px', // Extra large
'2xl': '1536px', // 2X extra large
}
}
}
```
#### Responsive Patterns
```jsx
// Hide/show at breakpoints
Visible on desktop
Visible on mobile
// Responsive layout
// Responsive grid
{items.map(item => )}
// Container with responsive padding
Responsive container
```
### Configuration
#### Theme Extension
**tailwind.config.js:**
```javascript
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ['./src/**/*.{js,jsx,ts,tsx}'],
theme: {
extend: {
colors: {
brand: {
50: '#f0f9ff',
100: '#e0f2fe',
500: '#0ea5e9',
900: '#0c4a6e',
},
accent: '#ff6b6b',
},
spacing: {
'18': '4.5rem',
'88': '22rem',
'128': '32rem',
},
fontFamily: {
sans: ['Inter', 'system-ui', 'sans-serif'],
display: ['Poppins', 'sans-serif'],
mono: ['Fira Code', 'monospace'],
},
fontSize: {
'2xs': '0.625rem',
'3xl': '2rem',
},
borderRadius: {
'4xl': '2rem',
},
boxShadow: {
'inner-lg': 'inset 0 2px 4px 0 rgb(0 0 0 / 0.1)',
},
animation: {
'slide-in': 'slideIn 0.3s ease-out',
'fade-in': 'fadeIn 0.2s ease-in',
},
keyframes: {
slideIn: {
'0%': { transform: 'translateX(-100%)' },
'100%': { transform: 'translateX(0)' },
},
fadeIn: {
'0%': { opacity: '0' },
'100%': { opacity: '1' },
},
},
},
},
plugins: [],
}
```
#### Custom Breakpoints
```javascript
module.exports = {
theme: {
screens: {
'xs': '475px',
'sm': '640px',
'md': '768px',
'lg': '1024px',
'xl': '1280px',
'2xl': '1536px',
'3xl': '1920px',
// Custom breakpoints
'tablet': '640px',
'laptop': '1024px',
'desktop': '1280px',
// Max-width breakpoints
'max-md': {'max': '767px'},
},
},
}
```
---
## Advanced Features
### Dark Mode
#### Class Strategy (Recommended)
**tailwind.config.js:**
```javascript
module.exports = {
darkMode: 'class', // or 'media' for OS preference
// ...
}
```
**Implementation:**
```jsx
// Toggle component
function DarkModeToggle() {
const [isDark, setIsDark] = useState(false);
useEffect(() => {
if (isDark) {
document.documentElement.classList.add('dark');
} else {
document.documentElement.classList.remove('dark');
}
}, [isDark]);
return (
);
}
// Dark mode styles
function Card() {
return (
Card Title
Card content adapts to dark mode
);
}
```
#### System Preference Strategy
```javascript
// tailwind.config.js
module.exports = {
darkMode: 'media', // Uses OS preference
}
```
```jsx
// Automatically adapts to system preference
Content adapts automatically
```
### Custom Utilities
#### Adding Custom Utilities
**tailwind.config.js:**
```javascript
const plugin = require('tailwindcss/plugin');
module.exports = {
plugins: [
plugin(function({ addUtilities, addComponents, theme }) {
// Custom utilities
addUtilities({
'.scrollbar-hide': {
'-ms-overflow-style': 'none',
'scrollbar-width': 'none',
'&::-webkit-scrollbar': {
display: 'none',
},
},
'.text-balance': {
'text-wrap': 'balance',
},
});
// Custom components
addComponents({
'.btn': {
padding: theme('spacing.4'),
borderRadius: theme('borderRadius.lg'),
fontWeight: theme('fontWeight.medium'),
'&:hover': {
opacity: 0.9,
},
},
'.card': {
backgroundColor: theme('colors.white'),
borderRadius: theme('borderRadius.lg'),
padding: theme('spacing.6'),
boxShadow: theme('boxShadow.lg'),
},
});
}),
],
}
```
#### Custom Variants
```javascript
const plugin = require('tailwindcss/plugin');
module.exports = {
plugins: [
plugin(function({ addVariant }) {
// Custom variant for third child
addVariant('third', '&:nth-child(3)');
// Custom variant for not-last child
addVariant('not-last', '&:not(:last-child)');
// Custom variant for group-hover with specific element
addVariant('group-hover-show', '.group:hover &');
}),
],
}
// Usage
Custom variant styles
```
### Plugins
#### Official Plugins
```bash
npm install -D @tailwindcss/forms @tailwindcss/typography @tailwindcss/aspect-ratio
```
**tailwind.config.js:**
```javascript
module.exports = {
plugins: [
require('@tailwindcss/forms'),
require('@tailwindcss/typography'),
require('@tailwindcss/aspect-ratio'),
],
}
```
#### Forms Plugin
```jsx
// Automatic form styling
```
#### Typography Plugin
```jsx
// Beautiful prose styling
Article Title
Automatic typography styles for markdown content...
- Styled lists
- Proper spacing
```
#### Aspect Ratio Plugin
```jsx
// Maintain aspect ratios
```
### Performance Optimization
#### Content Configuration
```javascript
// Optimize purge paths
module.exports = {
content: [
'./src/**/*.{js,jsx,ts,tsx}',
'./public/index.html',
// Include component libraries
'./node_modules/@my-ui/**/*.js',
],
// Safelist dynamic classes
safelist: [
'bg-red-500',
'bg-green-500',
{
pattern: /bg-(red|green|blue)-(400|500|600)/,
variants: ['hover', 'focus'],
},
],
}
```
#### JIT Mode (Default in v3+)
Just-In-Time compilation generates styles on-demand:
```jsx
// Arbitrary values work instantly
Custom value
Custom color
Custom grid
// No rebuild needed for new utilities
Star before
```
#### Build Optimization
```javascript
// postcss.config.js
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
// Production minification
...(process.env.NODE_ENV === 'production'
? { cssnano: {} }
: {}),
},
}
```
---
## Framework Integration
### React / Next.js
**Installation:**
```bash
npx create-next-app@latest my-app --tailwind
# or add to existing project
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
```
**next.config.js:**
```javascript
/** @type {import('next').NextConfig} */
module.exports = {
// Tailwind works out of box with Next.js
}
```
**_app.tsx:**
```typescript
import '@/styles/globals.css'
import type { AppProps } from 'next/app'
export default function App({ Component, pageProps }: AppProps) {
return
}
```
**Component Example:**
```tsx
// components/Button.tsx
import { ButtonHTMLAttributes, forwardRef } from 'react'
import { cva, type VariantProps } from 'class-variance-authority'
const buttonVariants = cva(
"inline-flex items-center justify-center rounded-lg font-medium transition-colors",
{
variants: {
variant: {
default: "bg-blue-600 text-white hover:bg-blue-700",
outline: "border border-gray-300 hover:bg-gray-100",
ghost: "hover:bg-gray-100",
},
size: {
sm: "px-3 py-1.5 text-sm",
md: "px-4 py-2",
lg: "px-6 py-3 text-lg",
},
},
defaultVariants: {
variant: "default",
size: "md",
},
}
)
interface ButtonProps
extends ButtonHTMLAttributes,
VariantProps {}
const Button = forwardRef(
({ className, variant, size, ...props }, ref) => {
return (
)
}
)
export default Button
```
### SvelteKit
**Installation:**
```bash
npx sv create my-app
# Select Tailwind CSS option
# or add to existing
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
```
**svelte.config.js:**
```javascript
import adapter from '@sveltejs/adapter-auto';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
export default {
preprocess: vitePreprocess(),
kit: {
adapter: adapter()
}
};
```
**Component Example:**
```svelte
```
### Vue 3
**Installation:**
```bash
npm create vue@latest my-app
# Select Tailwind CSS
# or add to existing
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
```
**main.ts:**
```typescript
import { createApp } from 'vue'
import App from './App.vue'
import './assets/main.css'
createApp(App).mount('#app')
```
**Component Example:**
```vue
```
---
## Component Patterns
### Layout Components
#### Container
```jsx
function Container({ children, size = 'default' }) {
const sizes = {
sm: 'max-w-3xl',
default: 'max-w-7xl',
full: 'max-w-full'
};
return (
{children}
);
}
```
#### Grid Layout
```jsx
function GridLayout({ children, cols = { default: 1, md: 2, lg: 3 } }) {
return (
{children}
);
}
```
#### Stack (Vertical Spacing)
```jsx
function Stack({ children, spacing = 4 }) {
return (
{children}
);
}
```
### UI Components
#### Card
```jsx
function Card({ title, description, image, footer }) {
return (
{image && (

)}
{footer && (
{footer}
)}
);
}
```
#### Modal
```jsx
function Modal({ isOpen, onClose, title, children }) {
if (!isOpen) return null;
return (
{/* Backdrop */}
{/* Modal */}
);
}
```
#### Form Input
```jsx
function Input({ label, error, ...props }) {
return (
{label && (
)}
{error && (
{error}
)}
);
}
```
#### Badge
```jsx
function Badge({ children, variant = 'default', size = 'md' }) {
const variants = {
default: 'bg-gray-100 text-gray-800',
primary: 'bg-blue-100 text-blue-800',
success: 'bg-green-100 text-green-800',
warning: 'bg-yellow-100 text-yellow-800',
danger: 'bg-red-100 text-red-800',
};
const sizes = {
sm: 'text-xs px-2 py-0.5',
md: 'text-sm px-2.5 py-1',
lg: 'text-base px-3 py-1.5',
};
return (
{children}
);
}
```
---
## Reference
### Common Utility Classes
#### Display & Positioning
```
display: block, inline-block, inline, flex, inline-flex, grid, inline-grid, hidden
position: static, fixed, absolute, relative, sticky
top/right/bottom/left: 0, auto, 1-96 (in 0.25rem increments)
z-index: z-0, z-10, z-20, z-30, z-40, z-50, z-auto
```
#### Flexbox & Grid
```
flex-direction: flex-row, flex-col, flex-row-reverse, flex-col-reverse
justify-content: justify-start, justify-center, justify-end, justify-between, justify-around
align-items: items-start, items-center, items-end, items-baseline, items-stretch
gap: gap-0 to gap-96 (in 0.25rem increments)
grid-cols: grid-cols-1 to grid-cols-12, grid-cols-none
```
#### Sizing
```
width: w-0 to w-96, w-auto, w-full, w-screen, w-1/2, w-1/3, w-2/3, etc.
height: h-0 to h-96, h-auto, h-full, h-screen
min/max-width: min-w-0, min-w-full, max-w-xs to max-w-7xl
min/max-height: min-h-0, min-h-full, max-h-screen
```
#### Spacing (0.25rem = 4px increments)
```
padding: p-0 to p-96, px-*, py-*, pt-*, pr-*, pb-*, pl-*
margin: m-0 to m-96, mx-*, my-*, mt-*, mr-*, mb-*, ml-*, -m-*
space-between: space-x-*, space-y-*
```
#### Typography
```
font-size: text-xs, text-sm, text-base, text-lg, text-xl to text-9xl
font-weight: font-thin to font-black (100-900)
text-align: text-left, text-center, text-right, text-justify
line-height: leading-none to leading-loose
letter-spacing: tracking-tighter to tracking-widest
```
#### Colors (50-900 scale)
```
text-{color}-{shade}: text-gray-500, text-blue-600, text-red-700
bg-{color}-{shade}: bg-white, bg-gray-100, bg-blue-500
border-{color}-{shade}: border-gray-300, border-blue-500
Colors: slate, gray, zinc, neutral, stone, red, orange, amber, yellow, lime,
green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia,
pink, rose
```
#### Borders
```
border-width: border, border-0, border-2, border-4, border-8
border-style: border-solid, border-dashed, border-dotted, border-double, border-none
border-radius: rounded-none, rounded-sm, rounded, rounded-lg, rounded-full
border-color: border-gray-300, etc.
```
#### Effects
```
shadow: shadow-sm, shadow, shadow-md, shadow-lg, shadow-xl, shadow-2xl, shadow-none
opacity: opacity-0 to opacity-100 (in 5% increments)
blur: blur-none, blur-sm, blur, blur-lg, blur-xl
```
#### Transitions & Animations
```
transition: transition-none, transition-all, transition, transition-colors, transition-opacity
duration: duration-75 to duration-1000 (ms)
timing: ease-linear, ease-in, ease-out, ease-in-out
animation: animate-none, animate-spin, animate-ping, animate-pulse, animate-bounce
```
### Responsive Breakpoints
```
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)
```
### State Variants
```
hover: &:hover
focus: &:focus
active: &:active
disabled: &:disabled
visited: &:visited (links)
checked: &:checked (inputs)
group-hover: .group:hover &
peer-focus: .peer:focus ~ &
first: &:first-child
last: &:last-child
odd: &:nth-child(odd)
even: &:nth-child(even)
```
### Dark Mode
```
dark: .dark &
dark:hover: .dark &:hover
dark:focus: .dark &:focus
```
---
## Best Practices
### Class Organization
```jsx
// Group classes logically
Content
```
### Extracting Components
```jsx
// DON'T repeat complex class strings
// DO extract to component
function Button({ children }) {
return (
);
}
```
### Using CSS Variables
```javascript
// tailwind.config.js
module.exports = {
theme: {
extend: {
colors: {
primary: 'rgb(var(--color-primary) / )',
secondary: 'rgb(var(--color-secondary) / )',
},
},
},
}
```
```css
/* globals.css */
:root {
--color-primary: 59 130 246; /* RGB values for blue-500 */
--color-secondary: 139 92 246; /* RGB values for purple-500 */
}
.dark {
--color-primary: 96 165 250; /* Lighter blue for dark mode */
--color-secondary: 167 139 250; /* Lighter purple for dark mode */
}
```
```jsx
// Usage with opacity
50% opacity primary color
```
### Avoiding Class Conflicts
```jsx
// DON'T use conflicting utilities
{/* text-left wins */}
// DO use conditional classes
// Or use clsx/cn utility
import { clsx } from 'clsx'
import { twMerge } from 'tailwind-merge'
function cn(...inputs) {
return twMerge(clsx(inputs))
}
```
---
## Troubleshooting
### Styles Not Applying
1. **Check content paths in config:**
```javascript
content: ['./src/**/*.{js,jsx,ts,tsx}']
```
2. **Verify CSS imports:**
```css
@tailwind base;
@tailwind components;
@tailwind utilities;
```
3. **Rebuild for dynamic classes:**
```javascript
// DON'T - won't be detected
// DO - use safelist or complete class names
```
### Build Size Issues
1. **Optimize content configuration**
2. **Remove unused plugins**
3. **Use environment-specific configs**
4. **Enable compression in production**
### Dark Mode Not Working
1. **Check darkMode setting in config**
2. **Verify 'dark' class on html/body**
3. **Test dark: variant syntax**
4. **Check system preferences (media strategy)**
---
## Resources
- **Official Docs:** https://tailwindcss.com/docs
- **Playground:** https://play.tailwindcss.com
- **Tailwind UI:** https://tailwindui.com (Premium components)
- **Headless UI:** https://headlessui.com (Unstyled accessible components)
- **Tailwind CLI:** https://tailwindcss.com/docs/installation
- **Class Variance Authority:** https://cva.style (Type-safe variants)
- **Prettier Plugin:** https://github.com/tailwindlabs/prettier-plugin-tailwindcss
[View on SkillFed](https://skillfed.io/bobmatnyc/claude-mpm-skills/tailwind) ยท [View on GitHub](https://github.com/bobmatnyc/claude-mpm-skills)