by jezweb
Claude 在配置 Tailwind CSS v4 与 shadcn/ui 时经常出错。本技能指导 Claude 遵循正确的四步模式:CSS 变量、Tailwind 映射、基础样式和自动深色模式,可防止 8 个已记录的常见错误。
1. 打开 Claude 聊天界面
2. 点击下方 "📋 复制" 按钮
3. 粘贴到 Claude 聊天框中并发送
4. 输入 "使用 tailwind-v4-shadcn 技能" 开始使用
=== tailwind-v4-shadcn 技能 === 作者: jezweb 描述: Claude 在配置 Tailwind CSS v4 与 shadcn/ui 时经常出错。本技能指导 Claude 遵循正确的四步模式:CSS 变量、Tailwind 映射、基础样式和自动深色模式,可防止 8 个已记录的常见错误。 使用方法: 1. 调用技能: "使用 tailwind-v4-shadcn 技能" 2. 提供相关信息: 根据技能要求提供必要参数 3. 查看结果: 技能会返回处理结果 示例: "使用 tailwind-v4-shadcn 技能,帮我分析一下这段代码"
这种方法适用于所有 Claude 用户,不需要安装额外工具。
productivity
safe
Status: Production Ready ✅ Last Updated: 2026-01-03 Production Tested: WordPress Auditor (https://wordpress-auditor.webfonts.workers.dev)
This skill should be invoked when user mentions ANY of:
tailwind v4tailwind css v4shadcn/uishadcn uivite + react + tailwind@tailwindcss/vitedark mode setuptheme providertheme switching@theme inlinecss variables not workingcolors not applyingtailwind utilities missingtw-animate-css (common error)@apply deprecateddark: variant not workingcolors all black/whitebg-primary doesn't work@import typography (wrong v4 syntax)require @tailwindcss/typography (v3 syntax in v4)prose class not working@plugin directiveSets up production-ready Vite + React + Tailwind CSS v4 + shadcn/ui with:
✅ Correct v4 architecture - @theme inline pattern, no config file ✅ Dark mode - ThemeProvider with system/light/dark support ✅ Error prevention - Fixes tw-animate-css, duplicate @layer, @apply deprecation ✅ Semantic colors - Full color palette with proper CSS variables ✅ Path aliases - @/* imports configured ✅ TypeScript - Full type safety ✅ Templates - Proven file templates ready to copy
| Issue | Why It Happens | How Skill Fixes It |
|---|---|---|
tw-animate-css import error | shadcn init adds non-existent import | Provides clean CSS template |
Duplicate @layer base | shadcn init adds second block with @apply | Single clean @layer block |
| Colors don't work | Missing @theme inline mapping | Complete mapping provided |
| Dark mode broken | No ThemeProvider or wrong setup | Full ThemeProvider template |
| Wrong config | tailwind.config.ts used for theme | Empty config, CSS-only theme |
| Double hsl() wrapping | Common pattern mistake | Correct variable usage |
| Wrong plugin syntax | Using @import or require() for plugins | Correct @plugin directive documented |
~/.claude/skills/tailwind-v4-shadcn/
├── README.md # This file - auto-trigger keywords
├── SKILL.md # Complete documentation (623 lines)
├── templates/ # Ready-to-copy file templates
│ ├── index.css # v4 CSS architecture
│ ├── components.json # shadcn/ui v4 config
│ ├── vite.config.ts # Vite + Tailwind plugin
│ ├── tsconfig.app.json # TypeScript with aliases
│ ├── theme-provider.tsx # Dark mode provider
│ └── utils.ts # cn() utility
└── reference/ # Deep-dive docs
├── architecture.md
├── dark-mode.md
├── common-gotchas.md
└── migration-guide.md
When Claude detects trigger keywords, it should:
tailwind-v4-shadcn skill. Use it?"templates/ directory| Approach | Tokens Used | Errors |
|---|---|---|
| Manual setup (no skill) | ~65,000 | 2-3 common errors |
| With this skill | ~20,000 | 0 (prevented) |
| Savings | ~70% | 100% reduction |
{
"dependencies": {
"tailwindcss": "^4.1.18",
"@tailwindcss/vite": "^4.1.18",
"clsx": "^2.1.1",
"tailwind-merge": "^3.4.0",
"react": "^19.2.0",
"react-dom": "^19.2.0"
},
"devDependencies": {
"@types/node": "^25.0.3",
"@vitejs/plugin-react": "^5.1.2",
"vite": "^7.3.0",
"typescript": "~5.9.0",
"tw-animate-css": "^1.4.0"
}
}
User: "Set up a new Vite + React project with Tailwind v4"
↓
Claude: [Checks ~/.claude/skills/tailwind-v4-shadcn/]
↓
Claude: "I found the tailwind-v4-shadcn skill. Use it?
(Prevents tw-animate-css error, includes dark mode)"
↓
User: "Yes"
↓
Claude: [Uses templates/ + follows SKILL.md]
↓
Result: Working project in ~1 minute, 0 errors
name: tailwind-v4-shadcn
version: 2.0.1
category: frontend-setup
stack: [vite, react, tailwind-v4, shadcn-ui]
confidence: high # Production-tested pattern
auto_invoke_threshold: 0.7 # Invoke if 70%+ match
maintained_by: jeremy@jezweb.net
last_tested: 2026-01-03
react-vite-base - Vite + React without Tailwindcloudflare-react-full-stack - Adds Cloudflare Workersreact-form-zod - React Hook Form + Zod validationSKILL.md (623 lines)reference/common-gotchas.mdView Count
0
Download Count
0
Favorite Count
0
Quality Score
76