Token导航 LogoToken导航TokenDH.com
研究检索需要联网clawhub未标认证来源可访问clear审计通过

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

Agent Skill

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

总安装

61,058

周安装

2,596

GitHub Stars

1

下载量

21,391
OpenClaw

安装说明

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

GitHub

来源数

2

许可证

MIT-0

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

复制命令到本机终端执行。该命令会通过 OpenClaw 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

ClawHubOpenClaw
openclaw skills install tailwind-v4-shadcn

简介

使用强制四步 CSS 变量主题配置 Tailwind v4 与 shadcn/ui,以启用自动暗模式并防止常见错误。

SKILL.md

name
tailwind-v4-+-shadcn/ui-stack
model
fast

Tailwind v4 + shadcn/ui Stack

Production-tested setup for Tailwind v4 with shadcn/ui. Prevents 8 documented errors through a mandatory four-step architecture.

WHAT

Complete Tailwind v4 + shadcn/ui configuration:

  • Four-step theming architecture (mandatory)
  • CSS variable-based color system
  • Automatic dark mode switching
  • Error prevention for 8 common mistakes
  • Migration guide from v3
  • Production-ready templates

WHEN

  • Starting a new React/Vite project with Tailwind v4
  • Migrating from Tailwind v3 to v4
  • Setting up shadcn/ui with Tailwind v4
  • Debugging: colors not working, dark mode broken, build failures
  • Fixing @theme inline, @apply, or @layer base issues

KEYWORDS

tailwind v4, tailwindcss 4, shadcn, shadcn/ui, @theme inline, dark mode, css variables, vite, tw-animate-css, tailwind config, migration

Production verified: WordPress Auditor (https://wordpress-auditor.webfonts.workers.dev) Versions: tailwindcss@4.1.18, @tailwindcss/vite@4.1.18

Installation

OpenClaw / Moltbot / Clawbot

npx clawhub@latest install tailwind-v4-shadcn

Quick Start

# 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 (v4 doesn't use it)
rm tailwind.config.ts

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": "",
    "css": "src/index.css",
    "baseColor": "slate",
    "cssVariables": true
  }
}

The Four-Step Architecture (MANDATORY)

Skipping steps breaks theming. Follow exactly:

Step 1: Define CSS Variables at Root

/* src/index.css */
@import "tailwindcss";
@import "tw-animate-css";

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

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

Critical: Define at root level (NOT inside @layer base). Use hsl() wrapper.

Step 2: Map Variables to Tailwind

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

Why: Generates utility classes (bg-background, text-primary). Without this, utilities don't exist.

Step 3: Apply Base Styles

@layer base {
  body {
    background-color: var(--background);
    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">
  {/* Theme switches automatically via .dark class */}
</div>

No dark: variants needed for semantic colors.


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
  2. Use .dark { @theme { } } (v4 doesn't support nested @theme)
  3. Double-wrap: hsl(var(--background))
  4. Use tailwind.config.ts for theme
  5. Use @apply with @layer base/components classes
  6. Use dark: variants for semantic colors

Common Errors & Solutions

Error 1: tw-animate-css Import

Error: Cannot find module 'tailwindcss-animate'

# Wrong (v3 package)
npm install tailwindcss-animate

# Correct (v4 package)
pnpm add -D tw-animate-css
@import "tailwindcss";
@import "tw-animate-css";

Error 2: Colors Not Working

Error: bg-primary doesn't apply styles

Cause: Missing @theme inline mapping

@theme inline {
  --color-primary: var(--primary);
  /* Map ALL variables */
}

Error 3: Dark Mode Not Switching

Cause: Missing ThemeProvider

See templates/theme-provider.tsx and wrap your app.

Error 4: Build Fails

Error: Unexpected config file

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

Error 5: @theme inline Breaks Multi-Theme

Cause: @theme inline bakes values at build time

Use @theme (without inline) for multi-theme systems:

/* For multi-theme (not just light/dark) */
@theme {
  --color-text-primary: var(--color-slate-900);
}

@layer theme {
  [data-theme="dark"] {
    --color-text-primary: var(--color-white);
  }
}

Error 6: @apply Breaking

Error: Cannot apply unknown utility class

v4 changed @apply behavior:

/* Wrong (v3 pattern) */
@layer components {
  .custom-button { @apply px-4 py-2; }
}

/* Correct (v4 pattern) */
@utility custom-button {
  @apply px-4 py-2;
}

Error 7: @layer base Styles Ignored

Cause: CSS layer cascade issues

/* Better: Don't use @layer base for critical styles */
body {
  background-color: var(--background);
}

Quick Reference

SymptomCauseFix
bg-primary doesn't workMissing @theme inlineAdd mapping
Colors black/whiteDouble hsl()Use var(--color) not hsl(var(--color))
Dark mode stuckMissing ThemeProviderWrap app
Build failstailwind.config.ts existsDelete file
Animation errorsWrong packageUse tw-animate-css

Tailwind v4 New Features

OKLCH Color Space

v4 uses OKLCH for perceptually uniform colors. Automatic sRGB fallbacks generated.

@theme {
  /* Modern approach */
  --color-brand: oklch(0.7 0.15 250);
  
  /* Legacy (still works) */
  --color-brand: hsl(240 80% 60%);
}

Container Queries (Built-in)

<div className="@container">
  <div className="@md:text-lg @lg:grid-cols-2">
    Content responds to container width
  </div>
</div>

Line Clamp (Built-in)

<p className="line-clamp-3">Truncate to 3 lines...</p>

Plugins

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

Migration from v3

Key Changes

  1. Delete tailwind.config.ts
  2. Move theme to CSS with @theme inline
  3. Replace tailwindcss-animatetw-animate-css
  4. Replace require()@plugin
  5. @apply in @layer components@utility

Color Migration

// Before: Hardcoded + dark variants
<div className="bg-blue-50 dark:bg-blue-950 text-blue-700 dark:text-blue-300">

// After: Semantic + automatic
<div className="bg-info/10 text-info">

Visual Changes

  • Ring width default: 3px → 1px (use ring-3 to match v3)
  • Heading styles removed from Preflight (add via @tailwindcss/typography or custom)

Files

  • templates/index.css - Complete CSS with all variables
  • templates/theme-provider.tsx - Dark mode provider
  • templates/vite.config.ts - Vite configuration
  • templates/components.json - shadcn/ui v4 config
  • templates/utils.ts - cn() utility
  • references/architecture.md - Deep dive on four-step pattern
  • references/migration-guide.md - Semantic color migration
  • references/dark-mode.md - Complete dark mode setup

Setup Checklist

  • [ ] @tailwindcss/vite installed
  • [ ] vite.config.ts uses tailwindcss() plugin
  • [ ] components.json has "config": ""
  • [ ] NO tailwind.config.ts exists
  • [ ] src/index.css follows 4-step pattern
  • [ ] ThemeProvider wraps app
  • [ ] Theme toggle works

NEVER

  • Put :root or .dark inside @layer base
  • Use tailwind.config.ts with v4 (it's ignored)
  • Double-wrap colors: hsl(var(--background))
  • Use tailwindcss-animate (use tw-animate-css)
  • Use @apply on @layer base/components classes in v4
  • Skip the @theme inline step

适合场景

01

OpenClaw 用户查找和安装 Skill 时

02

用户想查找某类 Agent Skill 时

03

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

04

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

能力 5

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

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

平台分布

OpenClaw

93.57%
按下载量换算20,016

安全审计

VirusTotal

通过

ClawScan

通过

Static analysis

未展示

权限和风险

需要联网

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

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills