tailwindcss
Tailwind CSS v4 utility-first styling patterns including responsive design, dark mode, and custom configuration. Use when styling with Tailwind, adding utility classes, configuring Tailwind, setting up dark mode, or customizing the theme.
Best use case
tailwindcss is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Tailwind CSS v4 utility-first styling patterns including responsive design, dark mode, and custom configuration. Use when styling with Tailwind, adding utility classes, configuring Tailwind, setting up dark mode, or customizing the theme.
Teams using tailwindcss should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/tailwindcss/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How tailwindcss Compares
| Feature / Agent | tailwindcss | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Tailwind CSS v4 utility-first styling patterns including responsive design, dark mode, and custom configuration. Use when styling with Tailwind, adding utility classes, configuring Tailwind, setting up dark mode, or customizing the theme.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Tailwind CSS v4 Development Guidelines
Best practices for using Tailwind CSS v4 utility classes effectively.
**Note**: Tailwind CSS v4 (released January 2025) uses a CSS-first configuration approach. If you need v3 compatibility, tailwind.config.js is still supported.
## Core Principles
1. **Utility-First**: Use utility classes instead of custom CSS
2. **Mobile-First**: Design for mobile, then scale up with responsive modifiers
3. **Component Extraction**: Extract repeated patterns into components
4. **Consistent Spacing**: Use Tailwind's spacing scale
5. **Custom Configuration**: Extend the default theme for brand consistency
## Basic Utilities
### Layout
```tsx
// Flexbox
<div className="flex items-center justify-between gap-4">
<div className="flex-1">Content</div>
<div className="flex-shrink-0">Sidebar</div>
</div>
// Grid
<div className="grid grid-cols-3 gap-4">
<div>1</div>
<div>2</div>
<div>3</div>
</div>
// Positioning
<div className="relative">
<div className="absolute top-0 right-0">Badge</div>
</div>
```
### Spacing
```tsx
// Padding and Margin
<div className="p-4 m-2"> {/* padding: 1rem, margin: 0.5rem */}
<div className="px-6 py-4"> {/* padding-x: 1.5rem, padding-y: 1rem */}
<div className="mt-8 mb-4"> {/* margin-top: 2rem, margin-bottom: 1rem */}
// Space between children
<div className="space-y-4"> {/* margin-bottom on all but last child */}
<div>Item 1</div>
<div>Item 2</div>
</div>
```
### Typography
```tsx
<h1 className="text-4xl font-bold text-gray-900">Heading</h1>
<p className="text-base font-normal text-gray-600 leading-relaxed">
Paragraph text with comfortable line height.
</p>
<span className="text-sm font-medium text-blue-600">Label</span>
```
### Colors
```tsx
// Text colors
<p className="text-gray-900 dark:text-gray-100">Text</p>
// Background colors
<div className="bg-blue-500 hover:bg-blue-600">Button</div>
// Border colors
<div className="border border-gray-300">Box</div>
```
## Responsive Design
### Breakpoints
```tsx
// Mobile-first responsive classes
<div className="w-full md:w-1/2 lg:w-1/3">
{/* Full width on mobile, half on medium screens, third on large */}
</div>
<h1 className="text-2xl md:text-4xl lg:text-6xl">
{/* Responsive text sizes */}
</h1>
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
{/* Responsive grid */}
</div>
```
### Container
```tsx
<div className="container mx-auto px-4">
{/* Centered container with horizontal padding */}
</div>
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
{/* Responsive container padding */}
</div>
```
## Component Patterns
### Button
```tsx
<button className="px-4 py-2 bg-blue-600 text-white font-medium rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed transition-colors">
Click me
</button>
// Variants
<button className="px-4 py-2 border border-gray-300 rounded-md hover:bg-gray-50">
Secondary
</button>
```
### Card
```tsx
<div className="bg-white rounded-lg shadow-md overflow-hidden">
<img src="/image.jpg" alt="" className="w-full h-48 object-cover" />
<div className="p-6">
<h2 className="text-xl font-semibold mb-2">Card Title</h2>
<p className="text-gray-600">Card content goes here.</p>
</div>
</div>
```
### Form Input
```tsx
<div className="space-y-2">
<label htmlFor="email" className="block text-sm font-medium text-gray-700">
Email
</label>
<input
type="email"
id="email"
className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
placeholder="you@example.com"
/>
<p className="text-sm text-gray-500">We'll never share your email.</p>
</div>
```
## State Variants
### Hover, Focus, Active
```tsx
<button className="bg-blue-500 hover:bg-blue-600 active:bg-blue-700 focus:ring-2 focus:ring-blue-500">
Interactive Button
</button>
<a href="#" className="text-blue-600 hover:text-blue-800 hover:underline">
Link
</a>
```
### Group Hover
```tsx
<div className="group">
<img src="/image.jpg" className="group-hover:opacity-75 transition-opacity" />
<p className="group-hover:text-blue-600">Hover the container</p>
</div>
```
### Disabled
```tsx
<button className="disabled:opacity-50 disabled:cursor-not-allowed" disabled>
Disabled Button
</button>
```
## Dark Mode
```css
/* Tailwind v4: Configure in app/globals.css */
@import "tailwindcss";
@media (prefers-color-scheme: dark) {
/* Or use class-based: .dark */
}
```
```tsx
// Usage (same as v3)
<div className="bg-white dark:bg-gray-900 text-gray-900 dark:text-gray-100">
<h1 className="text-gray-900 dark:text-white">Title</h1>
<p className="text-gray-600 dark:text-gray-400">Description</p>
</div>
```
## Custom Styles
### Arbitrary Values
```tsx
<div className="top-[117px]"> {/* Custom top value */}
<div className="bg-[#1da1f2]"> {/* Custom color */}
<div className="grid-cols-[200px_1fr]"> {/* Custom grid template */}
```
### @apply Directive
```css
/* components/button.css */
.btn-primary {
@apply px-4 py-2 bg-blue-600 text-white font-medium rounded-md;
@apply hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500;
@apply disabled:opacity-50 disabled:cursor-not-allowed;
}
```
## Configuration
### Tailwind v4: CSS-First Configuration
```css
/* app/globals.css */
@import "tailwindcss";
@theme {
/* Custom colors */
--color-brand-50: #eff6ff;
--color-brand-100: #dbeafe;
--color-brand-900: #1e3a8a;
/* Custom spacing */
--spacing-128: 32rem;
/* Custom fonts */
--font-family-sans: 'Inter', sans-serif;
/* Custom breakpoints */
--breakpoint-3xl: 1920px;
}
```
### Tailwind v3 Config (Still Supported)
```javascript
// tailwind.config.js (optional in v4)
module.exports = {
content: [
'./app/**/*.{js,ts,jsx,tsx,mdx}',
'./components/**/*.{js,ts,jsx,tsx,mdx}',
],
theme: {
extend: {
colors: {
brand: {
50: '#eff6ff',
100: '#dbeafe',
900: '#1e3a8a',
}
},
spacing: {
'128': '32rem',
},
fontFamily: {
sans: ['Inter', 'sans-serif'],
},
},
},
plugins: [
require('@tailwindcss/forms'),
require('@tailwindcss/typography'),
],
}
```
## Plugins
### Official Plugins
```bash
npm install @tailwindcss/forms
npm install @tailwindcss/typography
npm install @tailwindcss/aspect-ratio
npm install @tailwindcss/container-queries
```
```tsx
// @tailwindcss/forms
<input type="text" className="form-input rounded-md" />
// @tailwindcss/typography
<article className="prose lg:prose-xl">
<h1>Article Title</h1>
<p>Content...</p>
</article>
```
## Performance
### Automatic Content Detection
Tailwind v4 automatically detects and scans all template files - no `content` configuration needed.
### Build Performance
Tailwind v4 delivers 3.5x faster full builds (~100ms) compared to v3 using modern CSS features like `@property` and `color-mix()`.
**Browser Requirements**: Safari 16.4+, Chrome 111+, Firefox 128+
## Common Patterns
### Centered Content
```tsx
<div className="flex items-center justify-center min-h-screen">
<div>Centered content</div>
</div>
```
### Sticky Header
```tsx
<header className="sticky top-0 z-50 bg-white border-b">
<nav>Navigation</nav>
</header>
```
### Grid Layout
```tsx
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
{posts.map(post => (
<PostCard key={post.id} post={post} />
))}
</div>
```
### Truncate Text
```tsx
<p className="truncate">This text will be truncated with ellipsis if too long</p>
<p className="line-clamp-3">This text will show max 3 lines with ellipsis</p>
```
## Best Practices
1. **Use Consistent Spacing**: Stick to Tailwind's spacing scale
2. **Responsive by Default**: Always consider mobile-first design
3. **Extract Components**: Avoid repeating long class lists
4. **Use Theme Colors**: Define custom colors in config, not arbitrary values
5. **Leverage @apply Sparingly**: Prefer utility classes in JSX
6. **Enable Dark Mode**: Plan for dark mode from the start
7. **Use Plugins**: Leverage official plugins for common needs
8. **Optimize Production**: Ensure purge is configured correctly
## Additional Resources
For detailed information, see:
- [Utility Patterns](resources/utility-patterns.md)
- [Component Library](resources/component-library.md)
- [Configuration Guide](resources/configuration.md)Related Skills
web-design-guidelines
Review UI code for Web Interface Guidelines compliance. Use when asked to "review my UI", "check accessibility", "audit design", "review UX", or "check my site against best practices".
vercel-react-best-practices
React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.
ui-ux-pro-max
Comprehensive design guide for web and mobile applications. Contains 67 styles, 96 color palettes, 57 font pairings, 99 UX guidelines, and 25 chart types across 13 technology stacks. Searchable database with priority-based recommendations.
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with colors/fonts that you can apply to any artifact that has been creating, or can generate a new theme on-the-fly.
skill-creator
Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Claude's capabilities with specialized knowledge, workflows, or tool integrations.
run-tests
后端代码测试验证规则。此技能在以下情况下自动触发: - 任何后端代码修改(backend/ 目录下的 .py 文件) - 新增功能开发 - Bug 修复 - 代码重构 核心原则: 1. 后端代码修改必须有对应的测试用例 2. 修改业务逻辑时必须同步更新相关测试用例 3. 测试全部通过才算功能完成 触发关键词:后端、backend、python、测试、test、pytest、功能、feature、修复、fix、实现、修改、完成、验证 alwaysApply: true
release
发版流程 - 仔细阅读上个版本到现在版本的内容,把更改功能放到项目CHANGELOG.md目录下,处理README图片引用,然后提交且推送所有源码到GitHub和Gitee双平台,再之后打tag 触发条件:用户要求发版、发布、release、打tag
readme-images
Handle README.md image references for GitHub and Gitee platforms. Use when writing or converting README.md files that contain images, ensuring correct image paths for each platform. GitHub READMEs use Qiniu cloud URLs (via qiniu-upload skill), Gitee READMEs use local relative image paths.
qiniu-upload
Upload images to Qiniu Cloud (七牛云) via local PicList/PicGo service and return the public access URL. Use when the user needs to upload images, screenshots, or any picture files to Qiniu cloud storage, get image hosting URLs, or publish images to http://qiniu.biomed168.com/pic/.
mobile-automation
Mobile MCP + 飞书 MCP 双协作自动化测试专家。
image-compress
图片压缩检查规则。当添加或修改 README 引用的图片时自动触发。检查图片是否超过 100KB,超出则压缩。推荐使用 avif/webp 格式。触发场景:添加新图片到仓库、更新 README 中的截图、发版前检查。
frontend-design
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts, posters, or applications (examples include websites, landing pages, dashboards, React components, HTML/CSS layouts, or when styling/beautifying any web UI). Generates creative, polished code and UI design that avoids generic AI aesthetics.