tailwind-v4-shadcn by jezweb/claude-skills
npx skills add https://github.com/jezweb/claude-skills --skill tailwind-v4-shadcn生产环境验证 : WordPress Auditor (https://wordpress-auditor.webfonts.workers.dev) 最后更新 : 2026-01-20 版本 : tailwindcss@4.1.18, @tailwindcss/vite@4.1.18 状态 : 生产就绪 ✅
# 1. 安装依赖
pnpm add tailwindcss @tailwindcss/vite
pnpm add -D @types/node tw-animate-css
pnpm dlx shadcn@latest init
# 2. 删除 v3 配置文件(如果存在)
rm tailwind.config.ts # v4 不使用此文件
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') } }
})
components.json (关键):
{
"tailwind": {
"config": "", // ← v4 留空
"css": "src/index.css",
"baseColor": "slate",
"cssVariables": true
}
}
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
跳过步骤将破坏你的主题。请严格遵循:
/* src/index.css */
@import "tailwindcss";
@import "tw-animate-css"; /* shadcn/ui 动画所需 */
: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() 包装。
@theme inline {
--color-background: var(--background);
--color-foreground: var(--foreground);
--color-primary: var(--primary);
/* ... 映射所有 CSS 变量 */
}
原因 : 生成工具类(bg-background、text-primary)。没有这一步,工具类将不存在。
@layer base {
body {
background-color: var(--background); /* 此处不要使用 hsl() 包装 */
color: var(--foreground);
}
}
关键 : 直接引用变量。切勿双重包装:hsl(var(--background))。
<div className="bg-background text-foreground">
{/* 不需要 dark: 变体 - 主题自动切换 */}
</div>
1. 创建 ThemeProvider(参见 templates/theme-provider.tsx)
2. 包装应用 :
// src/main.tsx
import { ThemeProvider } from '@/components/theme-provider'
ReactDOM.createRoot(document.getElementById('root')!).render(
<ThemeProvider defaultTheme="dark" storageKey="vite-ui-theme">
<App />
</ThemeProvider>
)
3. 添加主题切换 :
pnpm dlx shadcn@latest add dropdown-menu
ModeToggle 组件请参见 reference/dark-mode.md。
:root/.dark 中用 hsl() 包装颜色:--bg: hsl(0 0% 100%);@theme inline 映射所有 CSS 变量"tailwind.config": ""tailwind.config.ts(如果存在)@tailwindcss/vite 插件(不是 PostCSS):root/.dark 放在 @layer base 内部(会导致层叠问题).dark { @theme { } } 模式(v4 不支持嵌套的 @theme)hsl(var(--background))tailwind.config.ts 配置主题(v4 会忽略它)@apply 指令(v4 已弃用,参见错误 #7)dark: 变体(自动处理)@apply 与 @layer base 或 @layer components 中的类一起使用(v4 破坏性变更 - 改用 @utility) | 来源@layer base 中(参见错误 #8) | 来源此技能可防止 8 个已记录的错误。
错误 : "Cannot find module 'tailwindcss-animate'"
原因 : shadcn/ui 在 v4 中弃用了 tailwindcss-animate。
解决方案 :
# ✅ 正确做法
pnpm add -D tw-animate-css
# 添加到 src/index.css:
@import "tailwindcss";
@import "tw-animate-css";
# ❌ 错误做法
npm install tailwindcss-animate # 仅 v3 使用
错误 : bg-primary 不应用样式
原因 : 缺少 @theme inline 映射
解决方案 :
@theme inline {
--color-background: var(--background);
--color-foreground: var(--foreground);
--color-primary: var(--primary);
/* ... 映射所有 CSS 变量 */
}
错误 : 主题保持浅色/深色不变
原因 : 缺少 ThemeProvider
解决方案 :
templates/theme-provider.tsx)main.tsx 中包装应用<html> 元素上的 .dark 类是否切换错误 : 控制台显示 "Duplicate @layer base"
原因 : shadcn init 会添加 @layer base - 不要添加另一个
解决方案 :
/* ✅ 正确 - 单个 @layer base */
@import "tailwindcss";
:root { --background: hsl(0 0% 100%); }
@theme inline { --color-background: var(--background); }
@layer base { body { background-color: var(--background); } }
错误 : "Unexpected config file"
原因 : v4 不使用 tailwind.config.ts(v3 遗留)
解决方案 :
rm tailwind.config.ts
v4 配置在 src/index.css 中使用 @theme 指令完成。
错误 : 当使用 @theme inline 与自定义变体(例如 data-mode="dark")时,深色模式不切换 来源 : GitHub 讨论 #18560
原因 : @theme inline 在构建时将变量值烘焙到工具类中。当深色模式更改底层 CSS 变量时,工具类不会更新,因为它们引用的是硬编码值,而不是变量。
发生原因 :
@theme inline 在构建时内联值:bg-primary → background-color: oklch(...)解决方案 : 对于多主题场景,使用 @theme(不带 inline):
/* ✅ 正确 - 使用不带 inline 的 @theme */
@custom-variant dark (&:where([data-mode=dark], [data-mode=dark] *));
@theme {
--color-text-primary: var(--color-slate-900);
--color-bg-primary: var(--color-white);
}
@layer theme {
[data-mode="dark"] {
--color-text-primary: var(--color-white);
--color-bg-primary: var(--color-slate-900);
}
}
何时使用 inline :
何时不使用 inline :
维护者指导 (Adam Wathan):
"在 v4 中,更符合惯例的是让实际生成的 CSS 引用你的主题变量。我个人只会在没有它就不工作的情况下使用 inline。"
错误 : Cannot apply unknown utility class: custom-button 来源 : GitHub 讨论 #17082
原因 : 在 v3 中,在 @layer base 和 @layer components 中定义的类可以与 @apply 一起使用。在 v4 中,这是一个破坏性的架构变更。
发生原因 : v4 不再"劫持"原生的 CSS @layer 规则。只有用 @utility 定义的类才可用于 @apply。
迁移 :
/* ❌ v3 模式(有效) */
@layer components {
.custom-button {
@apply px-4 py-2 bg-blue-500;
}
}
/* ✅ v4 模式(必需) */
@utility custom-button {
@apply px-4 py-2 bg-blue-500;
}
/* 或使用原生 CSS */
@layer base {
.custom-button {
padding: 1rem 0.5rem;
background-color: theme(colors.blue.500);
}
}
注意 : 此技能已不鼓励使用 @apply。此错误主要针对从 v3 迁移的用户。
错误 : 在 @layer base 中定义的样式似乎被忽略 来源 : GitHub 讨论 #16002 | 讨论 #18123
原因 : v4 使用原生 CSS 层。如果层没有显式排序,基础样式可能会被工具层覆盖,因为 CSS 层叠。
发生原因 :
@layer base/components/utilities 并特殊处理它们解决方案选项 1 : 显式定义层:
@import "tailwindcss/theme.css" layer(theme);
@import "tailwindcss/base.css" layer(base);
@import "tailwindcss/components.css" layer(components);
@import "tailwindcss/utilities.css" layer(utilities);
@layer base {
body {
background-color: var(--background);
}
}
解决方案选项 2(推荐):不使用 @layer base - 在根级别定义样式:
@import "tailwindcss";
:root {
--background: hsl(0 0% 100%);
}
body {
background-color: var(--background); /* 不需要 @layer */
}
适用于 : 所有基础样式,不仅仅是颜色变量。除非你理解 CSS 层排序,否则避免将任何样式包装在 @layer base 中。
| 症状 | 原因 | 修复方法 |
|---|---|---|
bg-primary 不生效 | 缺少 @theme inline | 添加 @theme inline 块 |
| 颜色全是黑色/白色 | 双重 hsl() 包装 | 使用 var(--color) 而不是 hsl(var(--color)) |
| 深色模式不切换 | 缺少 ThemeProvider | 用 <ThemeProvider> 包装应用 |
| 构建失败 | tailwind.config.ts 存在 | 删除文件 |
| 动画错误 | 使用 tailwindcss-animate | 安装 tw-animate-css |
Tailwind v4.0 将整个默认调色板替换为 OKLCH,这是一种感知均匀的色彩空间。来源 : Tailwind v4.0 发布 | OKLCH 迁移指南
为什么使用 OKLCH :
浏览器支持(2026 年 1 月):
自动回退 : Tailwind 为旧版浏览器生成 sRGB 回退:
.bg-blue-500 {
background-color: #3b82f6; /* sRGB 回退 */
background-color: oklch(0.6 0.24 264); /* 现代浏览器 */
}
自定义颜色 : 定义自定义颜色时,现在首选 OKLCH:
@theme {
/* 现代方法(首选) */
--color-brand: oklch(0.7 0.15 250);
/* 传统方法(仍然有效) */
--color-brand: hsl(240 80% 60%);
}
迁移 : 没有破坏性变更 - Tailwind 自动生成回退。对于新项目,使用支持 OKLCH 的工具处理自定义颜色。
容器查询(自 v4.0 起内置):
<div className="@container">
<div className="@md:text-lg @lg:grid-cols-2">
内容响应容器宽度,而不是视口
</div>
</div>
行截断(自 v3.3 起内置):
<p className="line-clamp-3">截断为 3 行并显示省略号...</p>
<p className="line-clamp-[8]">支持任意值</p>
<p className="line-clamp-(--teaser-lines)">支持 CSS 变量</p>
移除的插件 :
@tailwindcss/container-queries - 现在内置@tailwindcss/line-clamp - 自 v3.3 起内置使用 @plugin 指令(不是 require() 或 @import):
排版(用于 Markdown/CMS 内容):
pnpm add -D @tailwindcss/typography
@import "tailwindcss";
@plugin "@tailwindcss/typography";
<article class="prose dark:prose-invert">{{ content }}</article>
表单(跨浏览器表单样式):
pnpm add -D @tailwindcss/forms
@import "tailwindcss";
@plugin "@tailwindcss/forms";
容器查询(内置,无需插件):
<div className="@container">
<div className="@md:text-lg">响应容器宽度</div>
</div>
常见插件错误 :
/* ❌ 错误 - v3 语法 */
@import "@tailwindcss/typography";
/* ✅ 正确 - v4 语法 */
@plugin "@tailwindcss/typography";
@tailwindcss/vite 已安装(不是 postcss)vite.config.ts 使用 tailwindcss() 插件components.json 有 "config": ""tailwind.config.tssrc/index.css 遵循 4 步模式:
:root/.dark 在根级别(不在 @layer 中)hsl() 包装@theme inline 映射所有变量@layer base 使用未包装的变量在 templates/ 目录中可用:
cn() 工具函数完整指南请参见 reference/migration-guide.md。
关键变更 :
tailwind.config.ts@theme inline@tailwindcss/line-clamp(现在内置:line-clamp-*)tailwindcss-animate 替换为 tw-animate-cssrequire() → @plugin警告 : @tailwindcss/upgrade 工具经常无法迁移配置。来源 : 社区报告 | GitHub 讨论 #16642
常见失败 :
建议 : 不要依赖自动化迁移。而是遵循迁移指南中的手动步骤。
Tailwind v4 对 Preflight 采取了更简约的方法,移除了标题、列表和按钮的默认样式。来源 : GitHub 讨论 #16517 | Medium: 迁移问题
影响 :
<h1> 到 <h6>)以相同大小渲染解决方案 :
选项 1:对内容页面使用 @tailwindcss/typography :
pnpm add -D @tailwindcss/typography
@import "tailwindcss";
@plugin "@tailwindcss/typography";
<article className="prose dark:prose-invert">
{/* 所有元素自动样式化 */}
</article>
选项 2:添加自定义基础样式 :
@layer base {
h1 { @apply text-4xl font-bold mb-4; }
h2 { @apply text-3xl font-bold mb-3; }
h3 { @apply text-2xl font-bold mb-2; }
ul { @apply list-disc pl-6 mb-4; }
ol { @apply list-decimal pl-6 mb-4; }
}
建议 : 对于 Vite 项目,使用 @tailwindcss/vite 插件而不是 PostCSS。来源 : Medium: 迁移问题 | GitHub 讨论 #15764
为什么 Vite 插件更好 :
// ✅ Vite 插件 - 一行代码,无需 PostCSS 配置
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
plugins: [react(), tailwindcss()],
})
// ❌ PostCSS - 多个步骤,插件兼容性问题
// 1. 安装 @tailwindcss/postcss
// 2. 配置 postcss.config.js
// 3. 管理插件顺序
// 4. 调试插件冲突
报告的 PostCSS 问题 :
postcss-import、postcss-advanced-variables、tailwindcss/nesting@tailwindcss/postcss官方指导 : Vite 插件推荐用于 Vite 项目。PostCSS 用于遗留设置或非 Vite 环境。
环宽度默认值 : 从 3px 更改为 1px 来源 : Medium: 迁移指南
ring 类现在更细
使用 ring-3 来匹配 v3 外观
// v3: 3px 环 <button className="ring">按钮</button>
// v4: 1px 环(更细) <button className="ring">按钮</button>
// 匹配 v3 外观 <button className="ring-3">按钮</button>
最后更新 : 2026-01-20 技能版本 : 3.0.0 Tailwind v4 : 4.1.18(最新)生产环境 : WordPress Auditor (https://wordpress-auditor.webfonts.workers.dev)
更新日志 :
每周安装量
2.6K
仓库
GitHub 星标
666
首次出现
Jan 20, 2026
安全审计
安装于
opencode1.9K
claude-code1.8K
gemini-cli1.7K
codex1.7K
github-copilot1.5K
cursor1.3K
Production-tested : WordPress Auditor (https://wordpress-auditor.webfonts.workers.dev) Last Updated : 2026-01-20 Versions : tailwindcss@4.1.18, @tailwindcss/vite@4.1.18 Status : Production Ready ✅
# 1. Install dependencies
pnpm add tailwindcss @tailwindcss/vite
pnpm add -D @types/node tw-animate-css
pnpm dlx shadcn@latest init
# 2. Delete v3 config if exists
rm tailwind.config.ts # v4 doesn't use this file
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') } }
})
components.json (CRITICAL):
{
"tailwind": {
"config": "", // ← Empty for v4
"css": "src/index.css",
"baseColor": "slate",
"cssVariables": true
}
}
Skipping steps will break your theme. Follow exactly:
/* src/index.css */
@import "tailwindcss";
@import "tw-animate-css"; /* Required for shadcn/ui animations */
: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 : Define at root level (NOT inside @layer base). Use hsl() wrapper.
@theme inline {
--color-background: var(--background);
--color-foreground: var(--foreground);
--color-primary: var(--primary);
/* ... map ALL CSS variables */
}
Why : Generates utility classes (bg-background, text-primary). Without this, utilities won't exist.
@layer base {
body {
background-color: var(--background); /* NO hsl() wrapper here */
color: var(--foreground);
}
}
Critical : Reference variables directly. Never double-wrap: hsl(var(--background)).
<div className="bg-background text-foreground">
{/* No dark: variants needed - theme switches automatically */}
</div>
1. Create ThemeProvider (see templates/theme-provider.tsx)
2. Wrap App :
// src/main.tsx
import { ThemeProvider } from '@/components/theme-provider'
ReactDOM.createRoot(document.getElementById('root')!).render(
<ThemeProvider defaultTheme="dark" storageKey="vite-ui-theme">
<App />
</ThemeProvider>
)
3. Add Theme Toggle :
pnpm dlx shadcn@latest add dropdown-menu
See reference/dark-mode.md for ModeToggle component.
hsl() in :root/.dark: --bg: hsl(0 0% 100%);@theme inline to map all CSS variables"tailwind.config": "" in components.jsontailwind.config.ts if exists@tailwindcss/vite plugin (NOT PostCSS):root/.dark inside @layer base (causes cascade issues).dark { @theme { } } pattern (v4 doesn't support nested @theme)hsl(var(--background))tailwind.config.ts for theme (v4 ignores it)@apply directive (deprecated in v4, see error #7)dark: variants for semantic colors (auto-handled)@apply with @layer base or classes (v4 breaking change - use instead) | This skill prevents 8 documented errors.
Error : "Cannot find module 'tailwindcss-animate'"
Cause : shadcn/ui deprecated tailwindcss-animate for v4.
Solution :
# ✅ DO
pnpm add -D tw-animate-css
# Add to src/index.css:
@import "tailwindcss";
@import "tw-animate-css";
# ❌ DON'T
npm install tailwindcss-animate # v3 only
Error : bg-primary doesn't apply styles
Cause : Missing @theme inline mapping
Solution :
@theme inline {
--color-background: var(--background);
--color-foreground: var(--foreground);
--color-primary: var(--primary);
/* ... map ALL CSS variables */
}
Error : Theme stays light/dark
Cause : Missing ThemeProvider
Solution :
templates/theme-provider.tsx)main.tsx.dark class toggles on <html> elementError : "Duplicate @layer base" in console
Cause : shadcn init adds @layer base - don't add another
Solution :
/* ✅ Correct - single @layer base */
@import "tailwindcss";
:root { --background: hsl(0 0% 100%); }
@theme inline { --color-background: var(--background); }
@layer base { body { background-color: var(--background); } }
Error : "Unexpected config file"
Cause : v4 doesn't use tailwind.config.ts (v3 legacy)
Solution :
rm tailwind.config.ts
v4 configuration happens in src/index.css using @theme directive.
Error : Dark mode doesn't switch when using @theme inline with custom variants (e.g., data-mode="dark") Source : GitHub Discussion #18560
Cause : @theme inline bakes variable VALUES into utilities at build time. When dark mode changes the underlying CSS variables, utilities don't update because they reference hardcoded values, not variables.
Why It Happens :
@theme inline inlines VALUES at build time: bg-primary → background-color: oklch(...)Solution : Use @theme (without inline) for multi-theme scenarios:
/* ✅ CORRECT - Use @theme without inline */
@custom-variant dark (&:where([data-mode=dark], [data-mode=dark] *));
@theme {
--color-text-primary: var(--color-slate-900);
--color-bg-primary: var(--color-white);
}
@layer theme {
[data-mode="dark"] {
--color-text-primary: var(--color-white);
--color-bg-primary: var(--color-slate-900);
}
}
When to use inline :
When NOT to use inline :
Maintainer Guidance (Adam Wathan):
"It's more idiomatic in v4 for the actual generated CSS to reference your theme variables. I would personally only use inline when things don't work without it."
Error : Cannot apply unknown utility class: custom-button Source : GitHub Discussion #17082
Cause : In v3, classes defined in @layer base and @layer components could be used with @apply. In v4, this is a breaking architectural change.
Why It Happens : v4 doesn't "hijack" the native CSS @layer at-rule anymore. Only classes defined with @utility are available to @apply.
Migration :
/* ❌ v3 pattern (worked) */
@layer components {
.custom-button {
@apply px-4 py-2 bg-blue-500;
}
}
/* ✅ v4 pattern (required) */
@utility custom-button {
@apply px-4 py-2 bg-blue-500;
}
/* OR use native CSS */
@layer base {
.custom-button {
padding: 1rem 0.5rem;
background-color: theme(colors.blue.500);
}
}
Note : This skill already discourages @apply usage. This error is primarily for users migrating from v3.
Error : Styles defined in @layer base seem to be ignored Source : GitHub Discussion #16002 | Discussion #18123
Cause : v4 uses native CSS layers. Base styles CAN be overridden by utility layers due to CSS cascade if layers aren't explicitly ordered.
Why It Happens :
@layer base/components/utilities and processed them speciallySolution Option 1 : Define layers explicitly:
@import "tailwindcss/theme.css" layer(theme);
@import "tailwindcss/base.css" layer(base);
@import "tailwindcss/components.css" layer(components);
@import "tailwindcss/utilities.css" layer(utilities);
@layer base {
body {
background-color: var(--background);
}
}
Solution Option 2 (Recommended): Don't use @layer base - define styles at root level:
@import "tailwindcss";
:root {
--background: hsl(0 0% 100%);
}
body {
background-color: var(--background); /* No @layer needed */
}
Applies to : ALL base styles, not just color variables. Avoid wrapping ANY styles in @layer base unless you understand CSS layer ordering.
| Symptom | Cause | Fix |
|---|---|---|
bg-primary doesn't work | Missing @theme inline | Add @theme inline block |
| Colors all black/white | Double hsl() wrapping | Use var(--color) not hsl(var(--color)) |
| Dark mode not switching | Missing ThemeProvider | Wrap app in <ThemeProvider> |
Tailwind v4.0 replaced the entire default color palette with OKLCH, a perceptually uniform color space. Source : Tailwind v4.0 Release | OKLCH Migration Guide
Why OKLCH :
Browser Support (January 2026):
Automatic Fallbacks : Tailwind generates sRGB fallbacks for older browsers:
.bg-blue-500 {
background-color: #3b82f6; /* sRGB fallback */
background-color: oklch(0.6 0.24 264); /* Modern browsers */
}
Custom Colors : When defining custom colors, OKLCH is now preferred:
@theme {
/* Modern approach (preferred) */
--color-brand: oklch(0.7 0.15 250);
/* Legacy approach (still works) */
--color-brand: hsl(240 80% 60%);
}
Migration : No breaking changes - Tailwind generates fallbacks automatically. For new projects, use OKLCH-aware tooling for custom colors.
Container Queries (built-in as of v4.0):
<div className="@container">
<div className="@md:text-lg @lg:grid-cols-2">
Content responds to container width, not viewport
</div>
</div>
Line Clamp (built-in as of v3.3):
<p className="line-clamp-3">Truncate to 3 lines with ellipsis...</p>
<p className="line-clamp-[8]">Arbitrary values supported</p>
<p className="line-clamp-(--teaser-lines)">CSS variable support</p>
Removed Plugins :
@tailwindcss/container-queries - Built-in now@tailwindcss/line-clamp - Built-in since v3.3Use @plugin directive (NOT require() or @import):
Typography (for Markdown/CMS content):
pnpm add -D @tailwindcss/typography
@import "tailwindcss";
@plugin "@tailwindcss/typography";
<article class="prose dark:prose-invert">{{ content }}</article>
Forms (cross-browser form styling):
pnpm add -D @tailwindcss/forms
@import "tailwindcss";
@plugin "@tailwindcss/forms";
Container Queries (built-in, no plugin needed):
<div className="@container">
<div className="@md:text-lg">Responds to container width</div>
</div>
Common Plugin Errors :
/* ❌ WRONG - v3 syntax */
@import "@tailwindcss/typography";
/* ✅ CORRECT - v4 syntax */
@plugin "@tailwindcss/typography";
@tailwindcss/vite installed (NOT postcss)vite.config.ts uses tailwindcss() plugincomponents.json has "config": ""tailwind.config.ts existssrc/index.css follows 4-step pattern:
:root/.dark at root level (not in @layer)hsl()Available in templates/ directory:
cn() utilitySee reference/migration-guide.md for complete guide.
Key Changes :
tailwind.config.ts@theme inline@tailwindcss/line-clamp (now built-in: line-clamp-*)tailwindcss-animate with tw-animate-cssrequire() → @pluginWarning : The @tailwindcss/upgrade utility often fails to migrate configurations. Source : Community Reports | GitHub Discussion #16642
Common failures :
Recommendation : Don't rely on automated migration. Follow manual steps in the migration guide instead.
Tailwind v4 takes a more minimal approach to Preflight, removing default styles for headings, lists, and buttons. Source : GitHub Discussion #16517 | Medium: Migration Problems
Impact :
<h1> through <h6>) render at same sizeSolutions :
Option 1: Use @tailwindcss/typography for content pages :
pnpm add -D @tailwindcss/typography
@import "tailwindcss";
@plugin "@tailwindcss/typography";
<article className="prose dark:prose-invert">
{/* All elements styled automatically */}
</article>
Option 2: Add custom base styles :
@layer base {
h1 { @apply text-4xl font-bold mb-4; }
h2 { @apply text-3xl font-bold mb-3; }
h3 { @apply text-2xl font-bold mb-2; }
ul { @apply list-disc pl-6 mb-4; }
ol { @apply list-decimal pl-6 mb-4; }
}
Recommendation : Use @tailwindcss/vite plugin for Vite projects instead of PostCSS. Source : Medium: Migration Problems | GitHub Discussion #15764
Why Vite Plugin is Better :
// ✅ Vite Plugin - One line, no PostCSS config
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
plugins: [react(), tailwindcss()],
})
// ❌ PostCSS - Multiple steps, plugin compatibility issues
// 1. Install @tailwindcss/postcss
// 2. Configure postcss.config.js
// 3. Manage plugin order
// 4. Debug plugin conflicts
PostCSS Problems Reported :
postcss-import, postcss-advanced-variables, tailwindcss/nesting@tailwindcss/postcssOfficial Guidance : The Vite plugin is recommended for Vite projects. PostCSS is for legacy setups or non-Vite environments.
Ring Width Default : Changed from 3px to 1px Source : Medium: Migration Guide
ring class is now thinner
Use ring-3 to match v3 appearance
// v3: 3px ring <button className="ring">Button</button>
// v4: 1px ring (thinner) <button className="ring">Button</button>
// Match v3 appearance <button className="ring-3">Button</button>
Last Updated : 2026-01-20 Skill Version : 3.0.0 Tailwind v4 : 4.1.18 (Latest) Production : WordPress Auditor (https://wordpress-auditor.webfonts.workers.dev)
Changelog :
Weekly Installs
2.6K
Repository
GitHub Stars
666
First Seen
Jan 20, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode1.9K
claude-code1.8K
gemini-cli1.7K
codex1.7K
github-copilot1.5K
cursor1.3K
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
105,000 周安装
@layer components@utility@layer base without understanding CSS layer ordering (see error #8) | Source| Build fails | tailwind.config.ts exists | Delete file |
| Animation errors | Using tailwindcss-animate | Install tw-animate-css |
@theme inline maps all variables@layer base uses unwrapped variables