Token导航 LogoToken导航

Agent Skill · 研究检索

tailwind-v4-shadcn(Tailwind CSS V4 shadcn/ui 前端)

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

tailwind-v4-shadcn 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证为 MIT,第三方扫描已通过,按安装量在研究检索类的 73,675 个 Skill 里排第 2,252。

总安装 64,805周安装 2,676GitHub Stars 750下载 21,723核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
MIT

安装方式

通过对话安装

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

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

命令行安装

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

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

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

Tailwind v4 与 shadcn/ui 使用 CSS 变量和 @theme 内联模式。

四步架构:在根定义 CSS 变量,使用 @theme inline 映射到 Tailwind 实用程序 、应用基础样式、自动深色模式切换 防止 8 个已记录的错误,包括颜色映射失败、暗模式冲突、@apply 重大更改和 v3 迁移陷阱 需要@tailwindcss/vite 插件(不是 PostCSS)、components.json 中的空 Tailwind 配置以及用于主题切换的 ThemeProvider 包装器 支持 OKLCH 色彩空间(默认为 v4)、内置容器查询和线夹以及具有正确 CSS 层排序的多主题设置

来源仓库内路径:skills/tailwind-v4-shadcn

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/jezweb/claude-skills --skill tailwind-v4-shadc…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

tailwind-v4-shadcn 怎么安装?

在终端执行 npx skills add https://github.com/jezweb/claude-skills --skill tailwind-v4-shadcn。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

tailwind-v4-shadcn 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

tailwind-v4-shadcn 需要什么权限?

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

tailwind-v4-shadcn 是免费的吗?

来源标注的许可证是 MIT。本站不代收任何费用,也不托管安装包;能否商用、要不要署名,以许可证原文为准。

tailwind-v4-shadcn 用的人多吗?

公开数据是累计安装 64,805 次,近一周安装 2,676 次,下载 21,723 次,GitHub 750 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

tailwind-v4-shadcn 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 3 个目录同时收录,说明这个 Skill 流传比较广。
  • 许可证明确为 MIT,商用和分发边界好判断。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。
  • 需要许可证清楚、并且有第三方扫描结果的团队项目。

不太适合

  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
tailwind-v4-shadcn

Tailwind CSS V4 shadcn/ui 前端 · 本页

64,805750需要联网MIT通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Tailwind v4 + shadcn/ui Production Stack

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 ✅


Quick Start (Follow This Exact Order)

# 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
  }
}

The Four-Step Architecture (MANDATORY)

Skipping steps will break your theme. Follow exactly:

Step 1: Define CSS Variables at Root

/* 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.

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: Generates utility classes (bg-background, text-primary). Without this, utilities won't exist.

Step 3: Apply Base Styles

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

Critical: Reference variables directly. 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 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.


Critical Rules

✅ Always Do:

  1. Wrap colors with hsl() in :root/.dark: --bg: hsl(0 0% 100%);
  2. Use @theme inline to map all CSS variables
  3. Set "tailwind.config": "" in components.json
  4. Delete tailwind.config.ts if exists
  5. Use @tailwindcss/vite plugin (NOT PostCSS)

❌ Never Do:

  1. Put :root/.dark inside @layer base (causes cascade issues)
  2. Use .dark {@theme {}} pattern (v4 doesn't support nested @theme)
  3. Double-wrap colors: hsl(var(--background))
  4. Use tailwind.config.ts for theme (v4 ignores it)
  5. Use @apply directive (deprecated in v4, see error #7)
  6. Use dark: variants for semantic colors (auto-handled)
  7. Use @apply with @layer base or @layer components classes (v4 breaking change - use @utility instead) | Source
  8. Wrap ANY styles in @layer base without understanding CSS layer ordering (see error #8) | Source

Common Errors & Solutions

This skill prevents 8 documented errors.

1. ❌ tw-animate-css Import Error

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

2. ❌ Colors Not Working

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 */
}

3. ❌ Dark Mode Not Switching

Error: Theme stays light/dark

Cause: Missing ThemeProvider

Solution:

  1. Create ThemeProvider (see templates/theme-provider.tsx)
  2. Wrap app in main.tsx
  3. Verify .dark class toggles on <html> element

4. ❌ Duplicate @layer base

Error: "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); } }

5. ❌ Build Fails with tailwind.config.ts

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.


6. ❌ @theme inline Breaks Dark Mode in Multi-Theme Setups

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(...)
  • Dark mode overrides change the CSS variables, but utilities already have baked-in values
  • The CSS specificity chain breaks

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:

  • Single theme + dark mode toggle (like shadcn/ui default) ✅
  • Referencing other CSS variables that don't change ✅

When NOT to use inline:

  • Multi-theme systems (data-theme="blue" | "green" | etc.) ❌
  • Dynamic theme switching beyond light/dark ❌

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."

7. ❌ @apply with @layer base/components (v4 Breaking Change)

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.


8. ❌ @layer base Styles Not Applying

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:

  • v3: Tailwind intercepted @layer base/components/utilities and processed them specially
  • v4: Uses native CSS layers - if you don't import layers in the right order, precedence breaks
  • Styles ARE being applied, but utilities override them

Solution 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.


Quick Reference

SymptomCauseFix
bg-primary doesn't workMissing @theme inlineAdd @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 file
Animation errorsUsing tailwindcss-animateInstall tw-animate-css

What's New in Tailwind v4

OKLCH Color Space (December 2024)

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:

  • Perceptual consistency: HSL's "50% lightness" is visually inconsistent across hues (yellow appears much brighter than blue at same lightness)
  • Better gradients: Smooth transitions without muddy middle colors
  • Wider gamut: Supports colors beyond sRGB on modern displays
  • More vibrant colors: Eye-catching, saturated colors previously limited by sRGB

Browser Support (January 2026):

  • Chrome 111+, Firefox 113+, Safari 15.4+, Edge 111+
  • Global coverage: 93.1%

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.

Built-in Features (No Plugin Needed)

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.3

Tailwind v4 Plugins

Use @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";

Setup Checklist

  • @tailwindcss/vite installed (NOT postcss)
  • vite.config.ts uses tailwindcss() plugin
  • components.json has "config": ""
  • NO tailwind.config.ts exists
  • src/index.css follows 4-step pattern:

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

  • ThemeProvider wraps app
  • Theme toggle works

File Templates

Available in templates/ directory:

  • index.css - Complete CSS with all color variables
  • components.json - shadcn/ui v4 config
  • vite.config.ts - Vite + Tailwind plugin
  • theme-provider.tsx - Dark mode provider
  • utils.ts - cn() utility

Migration from v3

See reference/migration-guide.md for complete guide.

Key Changes:

  • Delete tailwind.config.ts
  • Move theme to CSS with @theme inline
  • Replace @tailwindcss/line-clamp (now built-in: line-clamp-*)
  • Replace tailwindcss-animate with tw-animate-css
  • Update plugins: require() → @plugin

Additional Migration Gotchas

Automated Migration Tool May Fail

Warning: The @tailwindcss/upgrade utility often fails to migrate configurations. Source: Community Reports | GitHub Discussion #16642

Common failures:

  • Typography plugin configurations
  • Complex theme extensions
  • Custom plugin setups

Recommendation: Don't rely on automated migration. Follow manual steps in the migration guide instead.

Default Element Styles Removed

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:

  • All headings (<h1> through <h6>) render at same size
  • Lists lose default padding
  • Visual regressions in existing projects

Solutions:

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; }
}
PostCSS Setup Complexity

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:

  • Error: "It looks like you're trying to use tailwindcss directly as a PostCSS plugin"
  • Multiple PostCSS plugins required: postcss-import, postcss-advanced-variables, tailwindcss/nesting
  • v4 PostCSS plugin is separate package: @tailwindcss/postcss

Official Guidance: The Vite plugin is recommended for Vite projects. PostCSS is for legacy setups or non-Vite environments.

Visual Changes

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>

Reference Documentation

  • architecture.md - Deep dive into 4-step pattern
  • dark-mode.md - Complete dark mode implementation
  • common-gotchas.md - Troubleshooting guide
  • migration-guide.md - v3 → v4 migration

Official Documentation


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:

  • v3.0.0 (2026-01-20): Major research update - added 3 TIER 1 errors (#6-8), expanded migration guide with community findings (TIER 2), added OKLCH color space section, PostCSS complexity warnings, and migration tool limitations
  • v2.0.1 (2026-01-03): Production verification
  • v2.0.0: Initial release with 5 documented errors

平台分布

Claude Code

27.12%
按下载量换算5,891

Cursor

22.58%
按下载量换算4,905

OpenCode

17.71%
按下载量换算3,847

Antigravity

11.39%
按下载量换算2,474

Gemini CLI

6.72%
按下载量换算1,460

Codex

3.03%
按下载量换算658

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

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

安装前确认

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

继续浏览同类 Skills