tailwind-v4-shadcn
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTailwind v4 + shadcn/ui Production Stack
Tailwind v4 + shadcn/ui 生产级技术栈
Production-tested: WordPress Auditor (https://wordpress-auditor.webfonts.workers.dev)
Last Updated: 2025-11-09
Status: Production Ready ✅
经生产验证: WordPress Auditor (https://wordpress-auditor.webfonts.workers.dev)
最后更新: 2025-11-09
状态: 可用于生产 ✅
⚠️ BEFORE YOU START (READ THIS!)
⚠️ 开始前必读(务必阅读!)
CRITICAL FOR AI AGENTS: If you're Claude Code helping a user set up Tailwind v4:
- Explicitly state you're using this skill at the start of the conversation
- Reference patterns from the skill rather than general knowledge
- Prevent known issues listed in
reference/common-gotchas.md - 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"
对AI Agent的重要提示: 如果你是帮用户搭建Tailwind v4的Claude Code:
- 对话开头明确说明你正在使用本技能
- 引用本技能中的模式而非通用知识
- 避免中列出的已知问题
reference/common-gotchas.md - 不要猜测 - 如有疑问,请查阅本技能文档
用户需执行的操作: 告知Claude优先检查本技能!
请说:"我正在搭建Tailwind v4 + shadcn/ui - 优先检查tailwind-v4-shadcn技能"
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
未启用技能时:
- ❌ 搭建耗时: ~5分钟
- ❌ 遇到错误: 2-3个(tw-animate-css、重复的@layer base)
- ❌ 所需手动修复: 2次以上提交
- ❌ Token消耗: ~65k
- ❌ 用户信心: 需要调试
启用技能后:
- ✅ 搭建耗时: ~1分钟
- ✅ 遇到错误: 0
- ✅ 所需手动修复: 0
- ✅ Token消耗: ~20k(减少70%)
- ✅ 用户信心: 一次性成功
Known Issues This Skill Prevents
本技能可避免的已知问题
- tw-animate-css import error (deprecated in v4)
- Duplicate @layer base blocks (shadcn init adds its own)
- Wrong template selection (vanilla TS vs React)
- Missing post-init cleanup (incompatible CSS rules)
- Wrong plugin syntax (using @import or require() instead of @plugin directive)
All of these are handled automatically when the skill is active.
- tw-animate-css导入错误(v4中已废弃旧版本)
- 重复的@layer base块(shadcn init会自动添加)
- 模板选择错误(原生TS和React混淆)
- 初始化后缺少清理步骤(不兼容的CSS规则)
- 插件语法错误(使用@import或require()而非@plugin指令)
技能启用后所有这些问题都会自动处理。
Quick Start (5 Minutes - Follow This Exact Order)
快速开始(5分钟 - 严格按顺序执行)
1. Install Dependencies
1. 安装依赖
bash
pnpm add tailwindcss @tailwindcss/vite
pnpm add -D @types/node
pnpm dlx shadcn@latest initbash
pnpm add tailwindcss @tailwindcss/vite
pnpm add -D @types/node
pnpm dlx shadcn@latest init2. Configure Vite
2. 配置Vite
typescript
// 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')
}
}
})typescript
// 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
3. 更新components.json
json
{
"tailwind": {
"config": "", // ← CRITICAL: Empty for v4
"css": "src/index.css",
"baseColor": "slate", // Base color palette
"cssVariables": true,
"prefix": "" // No prefix for utility classes
}
}json
{
"tailwind": {
"config": "", // ← 关键:v4版本此处留空
"css": "src/index.css",
"baseColor": "slate", // 基础调色板
"cssVariables": true,
"prefix": "" // 工具类无前缀
}
}4. Delete tailwind.config.ts
4. 删除tailwind.config.ts
bash
rm tailwind.config.ts # v4 doesn't use this filebash
rm tailwind.config.ts # v4不需要这个文件The Four-Step Architecture (CRITICAL)
四步架构(核心要求)
This pattern is mandatory - skipping steps will break your theme.
该模式是强制要求 - 跳过步骤会导致主题失效。
Step 1: Define CSS Variables at Root Level
步骤1:在根级别定义CSS变量
css
/* 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 wrapper on all color values
hsl() - ✅ Use for dark mode (NOT
.dark).dark { @theme { } }
css
/* src/index.css */
@import "tailwindcss";
:root {
--background: hsl(0 0% 100%); /* ← 必须用hsl()包裹 */
--foreground: hsl(222.2 84% 4.9%);
--primary: hsl(221.2 83.2% 53.3%);
/* ... 所有亮色模式颜色 */
}
.dark {
--background: hsl(222.2 84% 4.9%);
--foreground: hsl(210 40% 98%);
--primary: hsl(217.2 91.2% 59.8%);
/* ... 所有暗色模式颜色 */
}核心规则:
- ✅ 在根级别定义(不要放在内部)
@layer base - ✅ 所有颜色值都用包裹
hsl() - ✅ 暗色模式用(不要用
.dark).dark { @theme { } }
Step 2: Map Variables to Tailwind Utilities
步骤2:将变量映射到Tailwind工具类
css
@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, etc. won't exist
bg-primary
css
@theme inline {
--color-background: var(--background);
--color-foreground: var(--foreground);
--color-primary: var(--primary);
/* ... 映射所有CSS变量 */
}为什么需要这一步:
- 生成工具类(、
bg-background)text-primary - 没有这一步,等类不会存在
bg-primary
Step 3: Apply Base Styles
步骤3:应用基础样式
css
@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))
css
@layer base {
body {
background-color: var(--background); /* 此处不要加hsl() */
color: var(--foreground);
}
}核心规则:
- ✅ 直接引用变量:
var(--background) - ❌ 不要双层包裹:
hsl(var(--background))
Step 4: Result - Automatic Dark Mode
步骤4:效果 - 自动暗黑模式
tsx
<div className="bg-background text-foreground">
{/* No dark: variants needed - theme switches automatically */}
</div>tsx
<div className="bg-background text-foreground">
{/* 不需要dark:前缀 - 主题会自动切换 */}
</div>Dark Mode Setup
暗黑模式设置
1. Create ThemeProvider
1. 创建ThemeProvider
See for full implementation or use template:
reference/dark-mode.mdtypescript
// Copy from: templates/theme-provider.tsx完整实现请查看或使用模板:
reference/dark-mode.mdtypescript
// 复制自: templates/theme-provider.tsx2. Wrap Your App
2. 包裹你的应用
typescript
// 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>,
)typescript
// 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
3. 添加主题切换按钮
bash
pnpm dlx shadcn@latest add dropdown-menuSee for ModeToggle component code.
reference/dark-mode.mdbash
pnpm dlx shadcn@latest add dropdown-menuModeToggle组件代码请查看。
reference/dark-mode.mdCritical Rules (MUST FOLLOW)
核心规则(必须遵守)
✅ Always Do:
✅ 必须执行:
-
Wrap color values within
hsl()and:root.darkcss--background: hsl(0 0% 100%); /* ✅ Correct */ -
Useto map all CSS variables
@theme inlinecss@theme inline { --color-background: var(--background); } -
Setin components.json
"tailwind.config": ""json{ "tailwind": { "config": "" } } -
Deleteif it exists
tailwind.config.ts -
Useplugin (NOT PostCSS)
@tailwindcss/vite -
Usefor conditional classes
cn()typescriptimport { cn } from "@/lib/utils" <div className={cn("base", isActive && "active")} />
-
在和
:root中用.dark包裹颜色值hsl()css--background: hsl(0 0% 100%); /* ✅ 正确 */ -
使用映射所有CSS变量
@theme inlinecss@theme inline { --color-background: var(--background); } -
在components.json中设置
"tailwind.config": ""json{ "tailwind": { "config": "" } } -
如果存在请删除
tailwind.config.ts -
使用插件(不要用PostCSS)
@tailwindcss/vite -
使用处理条件类名
cn()typescriptimport { cn } from "@/lib/utils" <div className={cn("base", isActive && "active")} />
❌ Never Do:
❌ 禁止操作:
-
Putor
:rootinside.dark@layer basecss/* WRONG */ @layer base { :root { --background: hsl(...); } } -
Usepattern
.dark { @theme { } }css/* WRONG - v4 doesn't support nested @theme */ .dark { @theme { --color-primary: hsl(...); } } -
Double-wrap colorscss
/* WRONG */ body { background-color: hsl(var(--background)); } -
Usefor theme colors
tailwind.config.tstypescript/* WRONG - v4 ignores this */ export default { theme: { extend: { colors: { primary: 'hsl(var(--primary))' } } } } -
Usedirective (deprecated in v4)
@apply -
Usevariants for semantic colors
dark:tsx/* WRONG */ <div className="bg-primary dark:bg-primary-dark" /> /* CORRECT */ <div className="bg-primary" />
-
将或
:root放在.dark内部@layer basecss/* 错误 */ @layer base { :root { --background: hsl(...); } } -
使用模式
.dark { @theme { } }css/* 错误 - v4不支持嵌套@theme */ .dark { @theme { --color-primary: hsl(...); } } -
双层包裹颜色css
/* 错误 */ body { background-color: hsl(var(--background)); } -
使用定义主题颜色
tailwind.config.tstypescript/* 错误 - v4会忽略该配置 */ export default { theme: { extend: { colors: { primary: 'hsl(var(--primary))' } } } } -
使用指令(v4中已废弃)
@apply -
语义化颜色使用前缀
dark:tsx/* 错误 */ <div className="bg-primary dark:bg-primary-dark" /> /* 正确 */ <div className="bg-primary" />
Semantic Color Tokens
语义化颜色Token
Always use semantic names for colors:
css
: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:
tsx
<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>颜色始终使用语义化名称:
css
:root {
--destructive: hsl(0 84.2% 60.2%); /* 红色 - 错误、临界提示 */
--success: hsl(142.1 76.2% 36.3%); /* 绿色 - 成功状态 */
--warning: hsl(38 92% 50%); /* 黄色 - 警告 */
--info: hsl(221.2 83.2% 53.3%); /* 蓝色 - 提示、主色 */
}用法:
tsx
<div className="bg-destructive text-destructive-foreground">临界提示</div>
<div className="bg-success text-success-foreground">成功</div>
<div className="bg-warning text-warning-foreground">警告</div>
<div className="bg-info text-info-foreground">提示</div>Common Issues & Quick Fixes
常见问题与快速修复
| Symptom | Cause | Fix |
|---|---|---|
| Missing | Add |
| Colors all black/white | Double | Use |
| Dark mode not switching | Missing ThemeProvider | Wrap app in |
| Build fails | | Delete the file |
| Text invisible | Wrong contrast colors | Check color definitions in |
See for complete troubleshooting guide.
reference/common-gotchas.md| 症状 | 原因 | 修复方案 |
|---|---|---|
| 缺少 | 添加 |
| 颜色全为黑/白色 | 双层 | 使用 |
| 暗黑模式不切换 | 缺少ThemeProvider | 用 |
| 构建失败 | 存在 | 删除该文件 |
| 文字不可见 | 颜色对比度错误 | 检查 |
完整故障排查指南请查看。
reference/common-gotchas.mdFile Templates
文件模板
All templates are available in the directory:
templates/- 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 - utility for class merging
cn()
Copy these files to your project and customize as needed.
所有模板都可以在目录下获取:
templates/- index.css - 包含所有颜色变量的完整CSS配置
- components.json - shadcn/ui v4配置
- vite.config.ts - Vite + Tailwind插件配置
- tsconfig.app.json - 配置了路径别名的TypeScript配置
- theme-provider.tsx - 带localStorage的暗黑模式Provider
- utils.ts - 用于类名合并的工具函数
cn()
将这些文件复制到你的项目中按需自定义即可。
Complete Setup Checklist
完整搭建检查清单
- Vite + React + TypeScript project created
- installed (NOT postcss)
@tailwindcss/vite - uses
vite.config.tsplugintailwindcss() - has path aliases configured
tsconfig.json - exists with
components.json"config": "" - NO file exists
tailwind.config.ts - follows v4 pattern:
src/index.css- and
:rootat root level (not in @layer).dark - Colors wrapped with
hsl() - maps all variables
@theme inline - uses unwrapped variables
@layer base
-
- Theme provider installed and wrapping app
- Dark mode toggle component created
- Test theme switching works in browser
- 已创建Vite + React + TypeScript项目
- 已安装(不是postcss)
@tailwindcss/vite - 已使用
vite.config.ts插件tailwindcss() - 已配置路径别名
tsconfig.json - 存在且
components.json"config": "" - 不存在文件
tailwind.config.ts - 遵循v4模式:
src/index.css- 和
:root在根级别(不在@layer内部).dark - 颜色用包裹
hsl() - 已映射所有变量
@theme inline - 使用未包裹的变量
@layer base
-
- 已安装ThemeProvider并包裹应用
- 已创建暗黑模式切换组件
- 浏览器中测试主题切换正常
Advanced Topics
进阶主题
Custom Colors
自定义颜色
Add new semantic colors:
css
:root {
--brand: hsl(280 65% 60%);
--brand-foreground: hsl(0 0% 100%);
}
.dark {
--brand: hsl(280 75% 70%);
--brand-foreground: hsl(280 20% 10%);
}
@theme inline {
--color-brand: var(--brand);
--color-brand-foreground: var(--brand-foreground);
}Usage:
<div className="bg-brand text-brand-foreground">Branded</div>添加新的语义化颜色:
css
:root {
--brand: hsl(280 65% 60%);
--brand-foreground: hsl(0 0% 100%);
}
.dark {
--brand: hsl(280 75% 70%);
--brand-foreground: hsl(280 20% 10%);
}
@theme inline {
--color-brand: var(--brand);
--color-brand-foreground: var(--brand-foreground);
}用法:
<div className="bg-brand text-brand-foreground">品牌色内容</div>Migration from v3
从v3迁移
See for complete v3 → v4 migration steps.
reference/migration-guide.md完整的v3 → v4迁移步骤请查看。
reference/migration-guide.mdComponent Best Practices
组件最佳实践
-
Always use semantic tokenstsx
<Button variant="destructive">Delete</Button> /* ✅ */ <Button className="bg-red-600">Delete</Button> /* ❌ */ -
Usefor conditional styling
cn()tsximport { cn } from "@/lib/utils" <div className={cn( "base-class", isActive && "active-class", hasError && "error-class" )} /> -
Compose shadcn/ui componentstsx
<Dialog> <DialogTrigger asChild> <Button>Open</Button> </DialogTrigger> <DialogContent> <DialogHeader> <DialogTitle>Title</DialogTitle> </DialogHeader> </DialogContent> </Dialog>
-
始终使用语义化tokentsx
<Button variant="destructive">删除</Button> /* ✅ */ <Button className="bg-red-600">删除</Button> /* ❌ */ -
使用处理条件样式
cn()tsximport { cn } from "@/lib/utils" <div className={cn( "base-class", isActive && "active-class", hasError && "error-class" )} /> -
组合使用shadcn/ui组件tsx
<Dialog> <DialogTrigger asChild> <Button>打开</Button> </DialogTrigger> <DialogContent> <DialogHeader> <DialogTitle>标题</DialogTitle> </DialogHeader> </DialogContent> </Dialog>
Dependencies
依赖
✅ Install These
✅ 请安装以下依赖
json
{
"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.553.0",
"react": "^19.2.0",
"react-dom": "^19.2.0"
},
"devDependencies": {
"@types/node": "^24.10.0",
"@vitejs/plugin-react": "^5.1.0",
"vite": "^7.2.2",
"typescript": "~5.9.0",
"tw-animate-css": "^1.4.0"
}
}json
{
"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.553.0",
"react": "^19.2.0",
"react-dom": "^19.2.0"
},
"devDependencies": {
"@types/node": "^24.10.0",
"@vitejs/plugin-react": "^5.1.0",
"vite": "^7.2.2",
"typescript": "~5.9.0",
"tw-animate-css": "^1.4.0"
}
}Animation Packages (Updated Nov 2025)
动画包(2025年11月更新)
shadcn/ui has deprecated in favor of for Tailwind v4 compatibility.
tailwindcss-animatetw-animate-css✅ DO Install (v4-compatible):
bash
pnpm add -D tw-animate-cssThen add to :
src/index.csscss
@import "tailwindcss";
@import "tw-animate-css";❌ DO NOT Install:
bash
npm install tailwindcss-animate # Deprecated - v3 onlyWhy: is the official v4-compatible replacement for animations, required by shadcn/ui components.
tw-animate-cssReference: https://ui.shadcn.com/docs/tailwind-v4
shadcn/ui已废弃,改用以兼容Tailwind v4。
tailwindcss-animatetw-animate-css✅ 请安装(兼容v4):
bash
pnpm add -D tw-animate-css然后添加到:
src/index.csscss
@import "tailwindcss";
@import "tw-animate-css";❌ 不要安装:
bash
npm install tailwindcss-animate # 已废弃 - 仅支持v3原因: 是官方兼容v4的动画替换包,是shadcn/ui组件的必需依赖。
tw-animate-cssTailwind v4 Plugins
Tailwind v4插件
Tailwind v4 supports official plugins using the directive in CSS.
@pluginTailwind v4支持在CSS中使用指令引入官方插件。
@pluginOfficial Plugins (Tailwind Labs)
官方插件(Tailwind Labs出品)
Typography Plugin - Style Markdown/CMS Content
排版插件 - 为Markdown/CMS内容添加样式
When to use: Displaying blog posts, documentation, or any HTML from Markdown/CMS.
Installation:
bash
pnpm add -D @tailwindcss/typographyConfiguration (v4 syntax):
css
/* src/index.css */
@import "tailwindcss";
@plugin "@tailwindcss/typography";Usage:
html
<article class="prose lg:prose-xl dark:prose-invert">
{{ markdown_content }}
</article>Available classes:
- - Base typography styles
prose - ,
prose-sm,prose-base,prose-lg,prose-xl- Size variantsprose-2xl - - Dark mode styles
dark:prose-invert
适用场景: 展示博客文章、文档,或任何来自Markdown/CMS的HTML内容。
安装:
bash
pnpm add -D @tailwindcss/typography配置(v4语法):
css
/* src/index.css */
@import "tailwindcss";
@plugin "@tailwindcss/typography";用法:
html
<article class="prose lg:prose-xl dark:prose-invert">
{{ markdown_content }}
</article>可用类名:
- - 基础排版样式
prose - 、
prose-sm、prose-base、prose-lg、prose-xl- 尺寸变体prose-2xl - - 暗黑模式样式
dark:prose-invert
Forms Plugin - Reset Form Element Styles
表单插件 - 重置表单元素样式
When to use: Building custom forms without shadcn/ui components, or need consistent cross-browser form styling.
Installation:
bash
pnpm add -D @tailwindcss/formsConfiguration (v4 syntax):
css
/* src/index.css */
@import "tailwindcss";
@plugin "@tailwindcss/forms";What it does:
- Resets browser default form styles
- Makes form elements styleable with Tailwind utilities
- Fixes cross-browser inconsistencies for inputs, selects, checkboxes, radios
Note: Less critical for shadcn/ui users (they have pre-styled form components), but still useful for basic forms.
适用场景: 不使用shadcn/ui组件构建自定义表单,或是需要跨浏览器一致的表单样式。
安装:
bash
pnpm add -D @tailwindcss/forms配置(v4语法):
css
/* src/index.css */
@import "tailwindcss";
@plugin "@tailwindcss/forms";作用:
- 重置浏览器默认表单样式
- 让表单元素可以用Tailwind工具类自定义样式
- 修复input、select、checkbox、radio的跨浏览器不一致问题
注意: shadcn/ui用户必要性较低(已有预定义样式的表单组件),但对基础表单仍然有用。
Common Plugin Errors
常见插件错误
These errors happen when using v3 syntax in v4 projects:
❌ WRONG (v3 config file syntax):
js
// tailwind.config.js
module.exports = {
plugins: [require('@tailwindcss/typography')]
}❌ WRONG (@import instead of @plugin):
css
@import "@tailwindcss/typography"; /* Doesn't work */✅ CORRECT (v4 @plugin directive):
css
/* src/index.css */
@import "tailwindcss";
@plugin "@tailwindcss/typography";
@plugin "@tailwindcss/forms";这些错误是在v4项目中使用v3语法导致的:
❌ 错误(v3配置文件语法):
js
// tailwind.config.js
module.exports = {
plugins: [require('@tailwindcss/typography')]
}❌ 错误(用@import而非@plugin):
css
@import "@tailwindcss/typography"; /* 不生效 */✅ 正确(v4 @plugin指令):
css
/* src/index.css */
@import "tailwindcss";
@plugin "@tailwindcss/typography";
@plugin "@tailwindcss/forms";Built-in Features (No Plugin Needed)
内置功能(无需插件)
Container queries are built into Tailwind v4 core - no plugin needed:
tsx
<div className="@container">
<div className="@md:text-lg">
Responds to container width, not viewport
</div>
</div>❌ Don't install: (deprecated, now core feature)
@tailwindcss/container-queries容器查询已内置到Tailwind v4核心 - 无需插件:
tsx
<div className="@container">
<div className="@md:text-lg">
响应容器宽度而非视口宽度
</div>
</div>❌ 不要安装: (已废弃,现在是核心功能)
@tailwindcss/container-queriesReference Documentation
参考文档
For deeper understanding, see:
- architecture.md - Deep dive into the 4-step pattern
- dark-mode.md - Complete dark mode implementation
- common-gotchas.md - All the ways it can break (and fixes)
- migration-guide.md - Migrating hardcoded colors to CSS variables
如需深入理解,请查看:
- architecture.md - 四步模式的深度解析
- dark-mode.md - 完整暗黑模式实现
- common-gotchas.md - 所有可能出错的场景及修复方案
- migration-guide.md - 将硬编码颜色迁移到CSS变量
Official Documentation
官方文档
- shadcn/ui Vite Setup: https://ui.shadcn.com/docs/installation/vite
- shadcn/ui Tailwind v4 Guide: https://ui.shadcn.com/docs/tailwind-v4
- shadcn/ui Dark Mode (Vite): https://ui.shadcn.com/docs/dark-mode/vite
- Tailwind v4 Docs: https://tailwindcss.com/docs
- shadcn/ui Theming: https://ui.shadcn.com/docs/theming
- shadcn/ui Vite搭建指南: https://ui.shadcn.com/docs/installation/vite
- shadcn/ui Tailwind v4指南: https://ui.shadcn.com/docs/tailwind-v4
- shadcn/ui 暗黑模式(Vite): https://ui.shadcn.com/docs/dark-mode/vite
- Tailwind v4文档: https://tailwindcss.com/docs
- shadcn/ui 主题设置: https://ui.shadcn.com/docs/theming
Production Example
生产环境示例
This skill is based on the WordPress Auditor project:
- Live: https://wordpress-auditor.webfonts.workers.dev
- Stack: Vite + React 19 + Tailwind v4 + shadcn/ui + Cloudflare Workers
- Dark Mode: Full system/light/dark support
- Version: Tailwind v4.1.14 + shadcn/ui latest (Oct 2025)
All patterns in this skill have been validated in production.
Questions? Issues?
- Check first
reference/common-gotchas.md - Verify all steps in the 4-step architecture
- Ensure has
components.json"config": "" - Delete if it exists
tailwind.config.ts - Check official docs: https://ui.shadcn.com/docs/tailwind-v4
本技能基于WordPress Auditor项目构建:
- 线上地址: https://wordpress-auditor.webfonts.workers.dev
- 技术栈: Vite + React 19 + Tailwind v4 + shadcn/ui + Cloudflare Workers
- 暗黑模式: 完整支持系统/亮色/暗色切换
- 版本: Tailwind v4.1.14 + shadcn/ui最新版(2025年10月)
本技能中的所有模式都已在生产环境验证。
问题?反馈?
- 优先查看
reference/common-gotchas.md - 验证四步架构中的所有步骤
- 确保中
components.json"config": "" - 如果存在请删除
tailwind.config.ts - 查看官方文档: https://ui.shadcn.com/docs/tailwind-v4