Token导航 LogoToken导航TokenDH.com
前端设计需要联网github未标认证来源可访问clear审计通过

tailwind-v4-shadcnTailwind CSS V4 shadcn/ui 前端

Agent Skill

用于辅助前端页面、组件、样式和交互逻辑的开发与维护。它适合让 Agent 生成或审查 React、Next.js、Vue、Tailwind、CSS 等相关代码,整理组件结构,或定位布局和性能问题。使用时需要结合项目现有设计系统、路由和构建方式,避免只生成孤立片段;涉及页面改动时,应配合本地预览和构建检查确认视觉效果。

总安装

87,024

周安装

3,685

GitHub Stars

126

下载量

30,488
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:tailwind-v4-shadcn(Tailwind CSS V4 shadcn/ui 前端)
来源仓库:https://github.com/secondsky/claude-skills
仓库路径:skills/tailwind-v4-shadcn
安装命令:
npx skills add https://github.com/secondsky/claude-skills --skill tailwind-v4-shadcn
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/secondsky/claude-skills --skill tailwind-v4-shadcn

简介

Tailwind CSS v4 的生产就绪设置,具有 shadcn/ui、深色模式和 CSS 变量架构。

  • 四步架构:使用 hsl() 在根级别定义 CSS 变量
  • 包装器,通过 @theme inline 映射到 Tailwind 实用程序,应用基本样式,并启用自动深色模式切换
  • 基于 Vite 插件的配置(无 PostCSS 或 tailwind.config.ts
  • 需要);需要@tailwindcss/vite
  • 和空的“配置”
  • 在 Components.json 中
  • 破坏性、成功、警告和信息状态的语义颜色标记;通过具有 localStorage 持久性的 ThemeProvider 实现深色模式
  • 记录了常见的陷阱:已弃用的 tailwindcss-animate
  • 包,重复@layer基础
  • 块,双包装 hsl()
  • 值,以及使用 @import 的错误插件语法
  • 而不是@plugin
  • 指令

SKILL.md

Tailwind v4 + shadcn/ui Production Stack

Production-tested: WordPress Auditor (https://wordpress-auditor.webfonts.workers.dev) Last Updated: 2025-12-04 Status: Production Ready ✅

Table of Contents

  1. Before You Start
  2. Quick Start
  3. Four-Step Architecture
  4. Dark Mode Setup
  5. Critical Rules
  6. Semantic Color Tokens
  7. Common Issues & Fixes
  8. File Templates
  9. Setup Checklist
  10. Advanced Topics
  11. Dependencies
  12. Tailwind v4 Plugins
  13. Reference Documentation
  14. When to Load References

⚠️ BEFORE YOU START (READ THIS!)

CRITICAL FOR AI AGENTS: If you're Claude Code helping a user set up Tailwind v4:

  1. Explicitly state you're using this skill at the start of the conversation
  2. Reference patterns from the skill rather than general knowledge
  3. Prevent known issues listed in reference/common-gotchas.md
  4. Don't guess - if unsure, check the skill documentation

USER ACTION REQUIRED: Tell Claude to check this skill first!

Say: "I'm setting up Tailwind v4 + shadcn/ui - check the tailwind-v4-shadcn skill first"

Why This Matters (Real-World Results)

Without skill activation:

  • ❌ Setup time: ~5 minutes
  • ❌ Errors encountered: 2-3 (tw-animate-css, duplicate @layer base)
  • ❌ Manual fixes needed: 2+ commits
  • ❌ Token usage: ~65k
  • ❌ User confidence: Required debugging

With skill activation:

  • ✅ Setup time: ~1 minute
  • ✅ Errors encountered: 0
  • ✅ Manual fixes needed: 0
  • ✅ Token usage: ~20k (70% reduction)
  • ✅ User confidence: Instant success

Known Issues This Skill Prevents

  1. tw-animate-css import error (deprecated in v4)
  2. Duplicate @layer base blocks (shadcn init adds its own)
  3. Wrong template selection (vanilla TS vs React)
  4. Missing post-init cleanup (incompatible CSS rules)
  5. Wrong plugin syntax (using @import or require() instead of @plugin directive)

All of these are handled automatically when the skill is active.


Quick Start (5 Minutes - Follow This Exact Order)

1. Install Dependencies

bun add tailwindcss @tailwindcss/vite
# or: npm install tailwindcss @tailwindcss/vite

bun add -d @types/node

# Note: Using pnpm for shadcn init due to known Bun compatibility issues
# (bunx has "Script not found" and postinstall/msw problems)
pnpm dlx shadcn@latest init

2. Configure Vite

// vite.config.ts
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
import path from 'path'

export default defineConfig({
  plugins: [react(), tailwindcss()],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src')
    }
  }
})

3. Update components.json

{
  "tailwind": {
    "config": "",              // ← CRITICAL: Empty for v4
    "css": "src/index.css",
    "cssVariables": true
  }
}

4. Delete tailwind.config.ts

rm tailwind.config.ts  # v4 doesn't use this file

The Four-Step Architecture (CRITICAL)

This pattern is mandatory - skipping steps will break your theme.

Step 1: Define CSS Variables at Root Level

/* src/index.css */
@import "tailwindcss";

:root {
  --background: hsl(0 0% 100%);      /* ← hsl() wrapper required */
  --foreground: hsl(222.2 84% 4.9%);
  --primary: hsl(221.2 83.2% 53.3%);
  /* ... all light mode colors */
}

.dark {
  --background: hsl(222.2 84% 4.9%);
  --foreground: hsl(210 40% 98%);
  --primary: hsl(217.2 91.2% 59.8%);
  /* ... all dark mode colors */
}

Critical Rules:

  • ✅ Define at root level (NOT inside @layer base)
  • ✅ Use hsl() wrapper on all color values
  • ✅ Use .dark for dark mode (NOT .dark {@theme {}})

Step 2: Map Variables to Tailwind Utilities

@theme inline {
  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --color-primary: var(--primary);
  /* ... map ALL CSS variables */
}

Why This Is Required:

  • Generates utility classes (bg-background, text-primary)
  • Without this, bg-primary etc. won't exist

Step 3: Apply Base Styles

@layer base {
  body {
    background-color: var(--background);  /* NO hsl() here */
    color: var(--foreground);
  }
}

Critical Rules:

  • ✅ Reference variables directly: var(--background)
  • ❌ Never double-wrap: hsl(var(--background))

Step 4: Result - Automatic Dark Mode

<div className="bg-background text-foreground">
  {/* No dark: variants needed - theme switches automatically */}
</div>

Dark Mode Setup

1. Create ThemeProvider

See reference/dark-mode.md for full implementation or use template:

// Copy from: templates/theme-provider.tsx

2. Wrap Your App

// src/main.tsx
import { ThemeProvider } from '@/components/theme-provider'

ReactDOM.createRoot(document.getElementById('root')!).render(
  <React.StrictMode>
    <ThemeProvider defaultTheme="dark" storageKey="vite-ui-theme">
      <App />
    </ThemeProvider>
  </React.StrictMode>,
)

3. Add Theme Toggle

pnpm dlx shadcn@latest add dropdown-menu

See reference/dark-mode.md for ModeToggle component code.


Critical Rules (MUST FOLLOW)

✅ Always Do:

  1. Wrap color values with hsl() in :root and .dark --background: hsl(0 0% 100%); /* ✅ Correct */
  2. Use @theme inline to map all CSS variables @theme inline {--color-background: var(--background);}
  3. Set "tailwind.config": "" in components.json {"tailwind": {"config": ""}}
  4. Delete tailwind.config.ts if it exists
  5. Use @tailwindcss/vite plugin (NOT PostCSS)
  6. Use cn() for conditional classes import {cn} from "@/lib/utils" <div className={cn("base", isActive && "active")} />

❌ Never Do:

  1. Put :root or .dark inside @layer base /* WRONG */ @layer base {:root {--background: hsl(...);}}
  2. Use .dark {@theme {}} pattern /* WRONG - v4 doesn't support nested @theme */.dark {@theme {--color-primary: hsl(...);}}
  3. Double-wrap colors /* WRONG */ body {background-color: hsl(var(--background));}
  4. Use tailwind.config.ts for theme colors /* WRONG - v4 ignores this */ export default {theme: {extend: {colors: {primary: 'hsl(var(--primary))'}}}}
  5. Use @apply directive (deprecated in v4)
  6. Use dark: variants for semantic colors /* WRONG */ <div className="bg-primary dark:bg-primary-dark" /> /* CORRECT */ <div className="bg-primary" />

Semantic Color Tokens

Always use semantic names for colors:

:root {
  --destructive: hsl(0 84.2% 60.2%);        /* Red - errors, critical */
  --success: hsl(142.1 76.2% 36.3%);        /* Green - success states */
  --warning: hsl(38 92% 50%);               /* Yellow - warnings */
  --info: hsl(221.2 83.2% 53.3%);           /* Blue - info, primary */
}

Usage:

<div className="bg-destructive text-destructive-foreground">Critical</div>
<div className="bg-success text-success-foreground">Success</div>
<div className="bg-warning text-warning-foreground">Warning</div>
<div className="bg-info text-info-foreground">Info</div>

Common Issues & Quick Fixes

SymptomCauseFix
bg-primary doesn't workMissing @theme inline mappingAdd @theme inline block
Colors all black/whiteDouble hsl() wrappingUse var(--color) not hsl(var(--color))
Dark mode not switchingMissing ThemeProviderWrap app in <ThemeProvider>
Build failstailwind.config.ts existsDelete the file
Text invisibleWrong contrast colorsCheck color definitions in :root/.dark

See reference/common-gotchas.md for complete troubleshooting guide.


File Templates

All templates are available in the templates/ directory:

  • index.css - Complete CSS setup with all color variables
  • components.json - shadcn/ui v4 configuration
  • vite.config.ts - Vite + Tailwind plugin setup
  • tsconfig.app.json - TypeScript with path aliases
  • theme-provider.tsx - Dark mode provider with localStorage
  • utils.ts - cn() utility for class merging

Copy these files to your project and customize as needed.


Complete Setup Checklist

  • Vite + React + TypeScript project created
  • @tailwindcss/vite installed (NOT postcss)
  • vite.config.ts uses tailwindcss() plugin
  • tsconfig.json has path aliases configured
  • components.json exists with "config": ""
  • NO tailwind.config.ts file exists
  • src/index.css follows v4 pattern:

- :root and .dark at root level (not in @layer) - Colors wrapped with hsl() - @theme inline maps all variables - @layer base uses unwrapped variables

  • Theme provider installed and wrapping app
  • Dark mode toggle component created
  • Test theme switching works in browser

Advanced Topics

Load references/advanced-usage.md for advanced patterns including:

  • Custom Colors: Add semantic colors beyond default palette
  • v3 Migration: See references/migration-guide.md for complete guide
  • Component Best Practices: Semantic tokens, cn() utility, composition patterns

Quick Example:

:root { --brand: hsl(280 65% 60%); }
@theme inline { --color-brand: var(--brand); }

Usage: <div className="bg-brand">Branded</div>

For detailed patterns and component composition examples, load references/advanced-usage.md.


Dependencies

✅ Install These

{
  "dependencies": {
    "tailwindcss": "^4.1.17",
    "@tailwindcss/vite": "^4.1.17",
    "clsx": "^2.1.1",
    "tailwind-merge": "^3.3.1",
    "@radix-ui/react-*": "latest",
    "lucide-react": "^0.554.0",
    "react": "^19.2.0",
    "react-dom": "^19.2.0"
  },
  "devDependencies": {
    "@types/node": "^24.10.1",
    "@vitejs/plugin-react": "^5.1.1",
    "vite": "^7.2.4",
    "typescript": "~5.9.3"
  }
}

❌ NEVER Install These (Deprecated in v4)

# These packages will cause build errors:
bun add tailwindcss-animate  # ❌ Deprecated
# or: npm install tailwindcss-animate  # ❌ Deprecated

bun add tw-animate-css      # ❌ Doesn't exist

If you see import errors for these packages, remove them and use native CSS animations or @tailwindcss/motion instead.


Tailwind v4 Plugins

Tailwind v4 supports official plugins using the @plugin directive in CSS.

Quick Example:

@import "tailwindcss";
@plugin "@tailwindcss/typography";
@plugin "@tailwindcss/forms";

Common Error: ❌ WRONG: @import "@tailwindcss/typography" (doesn't work) ✅ CORRECT: @plugin "@tailwindcss/typography" (use @plugin directive)

Built-in Features: Container queries are now core (no @tailwindcss/container-queries plugin needed).

Load references/plugins-reference.md for complete documentation including Typography plugin (prose classes), Forms plugin, installation steps, and common plugin errors.


Reference Documentation

For deeper understanding, see:

  • common-gotchas.md - All the ways it can break (and fixes)
  • dark-mode.md - Complete dark mode implementation
  • migration-guide.md - Migrating hardcoded colors to CSS variables
  • plugins-reference.md - Official Tailwind v4 plugins (Typography, Forms)
  • advanced-usage.md - Custom colors and advanced patterns

When to Load References

Load reference files based on user's specific needs:

Load references/common-gotchas.md when:

  • User reports "colors not working" or "bg-primary doesn't exist"
  • Dark mode not switching properly
  • Build fails with Tailwind errors
  • User encounters any CSS/configuration issue
  • Debugging theme problems

Load references/dark-mode.md when:

  • User asks to implement dark mode
  • Theme switching not working
  • Need ThemeProvider component code
  • Questions about system theme detection

Load references/migration-guide.md when:

  • Migrating from Tailwind v3 to v4
  • User has hardcoded colors to migrate
  • Questions about v3 → v4 changes
  • Need migration checklist

Load references/plugins-reference.md when:

  • User needs Typography plugin (prose class)
  • User needs Forms plugin
  • Questions about @plugin directive
  • Plugin installation errors

Load references/advanced-usage.md when:

  • User asks about custom colors beyond defaults
  • Need advanced component patterns
  • Questions about component best practices
  • Component composition questions

Official Documentation


Production Example

This skill is based on the WordPress Auditor project:

All patterns in this skill have been validated in production.


Questions? Issues?

  1. Check reference/common-gotchas.md first
  2. Verify all steps in the 4-step architecture
  3. Ensure components.json has "config": ""
  4. Delete tailwind.config.ts if it exists
  5. Check official docs: https://ui.shadcn.com/docs/tailwind-v4

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

27.84%
按下载量换算8,488

Claude Code

24.31%
按下载量换算7,412

windsurf

15.75%
按下载量换算4,802

Cursor

13.92%
按下载量换算4,244

OpenCode

8.74%
按下载量换算2,665

github-copilot

3.11%
按下载量换算948

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills