Agent Skillslegions-developer/evilcharts › tailwind-css-patterns

tailwind-css-patterns

GitHub

提供 Tailwind CSS v4.1+ 实用工具类开发模式,涵盖响应式布局、Flexbox/Grid、暗色模式及组件样式构建,适用于 React/Vue/Svelte 前端 UI 开发与设计系统实现。

.agents/skills/tailwind-css-patterns/SKILL.md legions-developer/evilcharts

Trigger Scenarios

使用 Tailwind CSS 进行前端组件样式编写 构建响应式网页布局或网格系统 配置暗色模式支持 优化前端 CSS 工作流

Install

npx skills add legions-developer/evilcharts --skill tailwind-css-patterns -g -y
More Options

Non-standard path

npx skills add https://github.com/legions-developer/evilcharts/tree/main/.agents/skills/tailwind-css-patterns -g -y

Use without installing

npx skills use legions-developer/evilcharts@tailwind-css-patterns

指定 Agent (Claude Code)

npx skills add legions-developer/evilcharts --skill tailwind-css-patterns -a claude-code -g -y

安装 repo 全部 skill

npx skills add legions-developer/evilcharts --all -g -y

预览 repo 内 skill

npx skills add legions-developer/evilcharts --list

SKILL.md

Frontmatter
{
    "name": "tailwind-css-patterns",
    "description": "Provides comprehensive Tailwind CSS utility-first styling patterns including responsive design, layout utilities, flexbox, grid, spacing, typography, colors, and modern CSS best practices. Use when styling React\/Vue\/Svelte components, building responsive layouts, implementing design systems, or optimizing CSS workflow.",
    "allowed-tools": "Read, Write, Edit, Glob, Grep, Bash"
}

Tailwind CSS Development Patterns

Expert guide for building modern, responsive user interfaces with Tailwind CSS utility-first framework. Covers v4.1+ features including CSS-first configuration, custom utilities, and enhanced developer experience.

Overview

Provides actionable patterns for responsive, accessible UIs with Tailwind CSS v4.1+. Covers utility composition, dark mode, component patterns, and performance optimization.

When to Use

  • Styling React/Vue/Svelte components
  • Building responsive layouts and grids
  • Implementing design systems
  • Adding dark mode support
  • Optimizing CSS workflow

Quick Reference

Responsive Breakpoints

Prefix Min Width Description
sm: 640px Small screens
md: 768px Tablets
lg: 1024px Desktops
xl: 1280px Large screens
2xl: 1536px Extra large

Common Patterns

<!-- Center content -->
<div class="flex items-center justify-center min-h-screen">
  Content
</div>

<!-- Responsive grid -->
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
  <!-- Items -->
</div>

<!-- Card component -->
<div class="bg-white rounded-lg shadow-lg p-6">
  <h3 class="text-xl font-bold">Title</h3>
  <p class="text-gray-600">Description</p>
</div>

Instructions

  1. Start Mobile-First: Write base styles for mobile, add responsive prefixes (sm:, md:, lg:) for larger screens
  2. Use Design Tokens: Leverage Tailwind's spacing, color, and typography scales
  3. Compose Utilities: Combine multiple utilities for complex styles
  4. Extract Components: Create reusable component classes for repeated patterns
  5. Configure Theme: Customize design tokens in CSS with the @theme directive (v4 is CSS-first — there is no tailwind.config.js)
  6. Verify Changes: Test at each breakpoint using DevTools responsive mode. Check for visual regressions and accessibility issues before committing.

Examples

Responsive Card Component

function ProductCard({ product }: { product: Product }) {
  return (
    <div className="bg-white rounded-lg shadow-lg overflow-hidden sm:flex">
      <img className="h-48 w-full object-cover sm:h-auto sm:w-48" src={product.image} />
      <div className="p-6">
        <h3 className="text-lg font-semibold">{product.name}</h3>
        <button className="mt-4 px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700">
          Add to Cart
        </button>
      </div>
    </div>
  );
}

Dark Mode Toggle

<div class="bg-white dark:bg-gray-900 text-gray-900 dark:text-white">
  <h1 class="dark:text-white">Title</h1>
</div>

Form Input

<input
  class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
  placeholder="you@example.com"
/>

Best Practices

  1. Consistent Spacing: Use Tailwind's spacing scale (4, 8, 12, 16, etc.)
  2. Color Palette: Stick to Tailwind's color system for consistency
  3. Component Extraction: Extract repeated patterns into reusable components
  4. Utility Composition: Prefer utility classes over @apply for maintainability
  5. Semantic HTML: Use proper HTML elements with Tailwind classes
  6. Performance: v4 auto-detects template files (no content array) and ships only the utilities you use
  7. Accessibility: Include focus styles, ARIA labels, and respect user preferences (reduced-motion)

Troubleshooting

Classes Not Applying

  • Check @import "tailwindcss": Ensure it's at the top of your CSS entry file (v4 replaces the old @tailwind directives)
  • Source detection: v4 auto-scans your project; if a file is ignored (e.g. via .gitignore), include it explicitly with @source "./path"
  • Verify build: Restart the dev server / rebuild so the v4 engine re-scans for class names

Responsive Styles Not Working

  • Order matters: Responsive prefixes must come before non-responsive (e.g., md:flex not flex md:flex)
  • Check breakpoint values: Verify breakpoints match your design requirements
  • DevTools: Use browser DevTools responsive mode to test at each breakpoint

Dark Mode Issues

  • Define the variant: v4 uses class-based dark mode via @custom-variant dark (&:where(.dark, .dark *)); in CSS (no darkMode config key)
  • Toggle implementation: Use document.documentElement.classList.toggle('dark') for class strategy
  • Initial flash: Add dark class to <html> before body renders

Constraints and Warnings

  • Class Proliferation: Long class strings reduce readability; extract into components
  • Content Paths: Misconfigured paths cause classes to be purged in production
  • Arbitrary Values: Use sparingly; prefer design tokens for consistency
  • Specificity Issues: Avoid @apply with complex selectors
  • Dark Mode: Requires correct configuration (class or media strategy)
  • Browser Support: Check Tailwind docs for compatibility notes

References

External Resources

Version History

  • 5eb23dc Current 2026-08-20 09:23

Same Skill Collection

.agents/skills/accessibility/SKILL.md
.agents/skills/animation-vocabulary/SKILL.md
.agents/skills/composition-patterns/SKILL.md
.agents/skills/emil-design-eng/SKILL.md
.agents/skills/frontend-design/SKILL.md
.agents/skills/hallmark/SKILL.md
.agents/skills/nodejs-backend-patterns/SKILL.md
.agents/skills/nodejs-best-practices/SKILL.md
.agents/skills/react-best-practices/SKILL.md
.agents/skills/review-animations/SKILL.md
.agents/skills/seo/SKILL.md
.agents/skills/setup-matt-pocock-skills/SKILL.md
.agents/skills/shadcn/SKILL.md
.agents/skills/tailwind-v4-shadcn/SKILL.md
.agents/skills/typescript-advanced-types/SKILL.md
.agents/skills/zod/SKILL.md
.agents/skills/agent-browser/SKILL.md
.agents/skills/commit-and-push/SKILL.md
.agents/skills/copywriting/SKILL.md
.agents/skills/improve/SKILL.md
.agents/skills/seo-audit/SKILL.md
.claude/skills/agent-browser/SKILL.md
.claude/skills/commit-and-push/SKILL.md

Metadata

Files
0
Version
5eb23dc
Hash
36779e75
Indexed
2026-08-20 09:23

- 위키
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-26 00:39
浙ICP备14020137号-1 $방문자$