Communitygithub.com

jezweb/shadcn-ui

安装和配置 React 项目中的 shadcn/ui 组件。指导组件选择、安装顺序、依赖管理、使用语义化 token 进行定制,以及常见 UI 方案(表单、数据表格、导航、模态框)。在 tailwind-theme-builder 完成主题基础设施搭建后使用,用于添加组件、构建表单、创建数据表格或设置导航。

shadcn-ui 是什么?

这是一个用于在 React 项目中安装和配置 shadcn/ui 组件的 AI 技能。它提供了详细的指导,帮助开发者选择合适的组件、确定安装顺序、管理依赖关系,并通过语义化 token 进行深度定制。该技能涵盖了常见的 UI 方案(recipes),包括表单、数据表格、导航和模态框的实现。在用例上,它适合在 tailwind-theme-builder 设置好主题基础设施之后使用,例如添加新组件、构建复杂表单、创建数据表格或设置导航系统。该技能支持主流 AI 编码工具(如 Claude Code、Cursor、Codex 等),通过清晰的结构化文档指导开发者高效地集成 shadcn/ui 组件库,提升 UI 开发效率并确保一致性。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/jezweb/claude-skills/tree/main/skills/shadcn-ui

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

shadcn-ui 是做什么的?

安装和配置 React 项目中的 shadcn/ui 组件。指导组件选择、安装顺序、依赖管理、使用语义化 token 进行定制,以及常见 UI 方案(表单、数据表格、导航、模态框)。在 tailwind-theme-builder 完成主题基础设施搭建后使用,用于添加组件、构建表单、创建数据表格或设置导航。

概述

本技能帮助你在 React 项目中安装和配置 shadcn/ui 组件。它提供逐步指导,涵盖组件选择、安装顺序、依赖管理、通过语义化 token 进行定制,以及常见 UI 方案(表单、数据表格、导航、模态框)。建议在 tailwind-theme-builder 技能完成主题基础设施搭建后再运行此技能。

组件安装

安装 shadcn/ui CLI

npx shadcn@latest init

安装组件

npx shadcn@latest add [component-name]

示例:

npx shadcn@latest add button
npx shadcn@latest add card
npx shadcn@latest add form

安装顺序

推荐安装顺序:

  1. 基础组件:button, card, input, label
  2. 布局组件:container, grid, flex
  3. 表单组件:form, select, checkbox, radio-group
  4. 反馈组件:dialog, alert, toast
  5. 导航组件:navigation-menu, tabs, breadcrumb
  6. 数据表格:table, pagination, dropdown-menu

依赖管理

shadcn/ui 依赖以下包:

  • react (>=18)
  • react-dom (>=18)
  • tailwindcss (>=3.4)
  • tailwind-merge
  • class-variance-authority
  • clsx

通过语义化 token 定制主题

无需手动编辑 CSS 变量,使用语义化 token 进行定制:

export const themeTokens = {
  colors: {
    primary: {
      DEFAULT: '#3b82f6',
      foreground: '#ffffff',
    },
    secondary: {
      DEFAULT: '#6b7280',
      foreground: '#ffffff',
    },
    destructive: {
      DEFAULT: '#ef4444',
      foreground: '#ffffff',
    },
  },
};

常见 UI 方案

表单

import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"

export function LoginForm() {
  return (
    <form>
      <div className="grid w-full max-w-sm items-center gap-1.5">
        <Label htmlFor="email">邮箱</Label>
        <Input type="email" id="email" placeholder="请输入邮箱" />
      </div>
      <div className="grid w-full max-w-sm items-center gap-1.5 mt-4">
        <Label htmlFor="password">密码</Label>
        <Input type="password" id="password" placeholder="请输入密码" />
      </div>
      <Button type="submit" className="mt-4">登录</Button>
    </form>
  )
}

数据表格

import {
  Table,
  TableBody,
  TableCell,
  TableHead,
  TableHeader,
  TableRow,
} from "@/components/ui/table"

export function DataTable() {
  return (
    <Table>
      <TableHeader>
        <TableRow>
          <TableHead>姓名</TableHead>
          <TableHead>邮箱</TableHead>
          <TableHead>角色</TableHead>
        </TableRow>
      </TableHeader>
      <TableBody>
        <TableRow>
          <TableCell>张三</TableCell>
          <TableCell>[email protected]</TableCell>
          <TableCell>管理员</TableCell>
        </TableRow>
      </TableBody>
    </Table>
  )
}

导航

import {
  NavigationMenu,
  NavigationMenuItem,
  NavigationMenuLink,
  NavigationMenuList,
} from "@/components/ui/navigation-menu"

export function Navigation() {
  return (
    <NavigationMenu>
      <NavigationMenuList>
        <NavigationMenuItem>
          <NavigationMenuLink href="/">首页</NavigationMenuLink>
        </NavigationMenuItem>
        <NavigationMenuItem>
          <NavigationMenuLink href="/about">关于</NavigationMenuLink>
        </NavigationMenuItem>
        <NavigationMenuItem>
          <NavigationMenuLink href="/contact">联系</NavigationMenuLink>
        </NavigationMenuItem>
      </NavigationMenuList>
    </NavigationMenu>
  )
}

模态框

import {
  Dialog,
  DialogContent,
  DialogDescription,
  DialogHeader,
  DialogTitle,
  DialogTrigger,
} from "@/components/ui/dialog"
import { Button } from "@/components/ui/button"

export function ConfirmDialog() {
  return (
    <Dialog>
      <DialogTrigger asChild>
        <Button variant="outline">打开对话框</Button>
      </DialogTrigger>
      <DialogContent>
        <DialogHeader>
          <DialogTitle>确认操作</DialogTitle>
          <DialogDescription>
            你确定要执行此操作吗?此操作无法撤销。
          </DialogDescription>
        </DialogHeader>
        <div className="flex justify-end gap-4">
          <Button variant="outline">取消</Button>
          <Button variant="destructive">确认</Button>
        </div>
      </DialogContent>
    </Dialog>
  )
}

最佳实践

  1. 保持组件简单:仅安装你需要的组件
  2. 遵循命名约定:使用 shadcn/ui 默认的命名空间
  3. 使用语义化 token:利用 CSS 变量实现主题一致性
  4. 顺序安装:按照依赖顺序安装组件以避免冲突
  5. 测试:在集成后始终测试组件行为

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

jezweb/ai-image-generator

Generate AI images using Gemini or GPT APIs directly. Covers model selection (Gemini for scenes; GPT Image 2 for text rendering, batch variations, multi-reference compositing; GPT Image 1.5 for transparent icons), the 5-part prompting framework, API calling patterns, multi-turn editing, and quality assurance. Produces photorealistic scenes, icons, illustrations, OG images, posters, infographics, and product shots. Use when building websites that need images, creating marketing assets, or generating visual content. Triggers: 'generate image', 'ai image', 'create hero image', 'make an icon', 'generate illustration', 'create og image', 'poster', 'infographic', 'image variations', 'gpt-image-2', 'ai art', 'image generation'.

jezweb/aussie-business-english

Australian business English writing style for professional communications — warm, direct, EN-AU spelling (colour, organise, centre). Use whenever the user is writing for an Australian audience: emails, chat messages, proposals, client communications, blog posts, web copy, or any business writing. Apply to drafting, editing, and tone-checking professional text.

jezweb/claude-skills

Generate project documentation from codebase analysis — ARCHITECTURE.md, API_ENDPOINTS.md, DATABASE_SCHEMA.md. Reads source code, schema files, routes, and config to produce accurate, structured docs. Use when starting a project, onboarding contributors, or when docs are missing or stale. Triggers: 'generate docs', 'document architecture', 'create api docs', 'document schema', 'project documentation', 'write architecture doc'.

jezweb/claude-skills

Agent skill at plugins/social-media/skills/social-media-posts/SKILL.md

jezweb/claude-skills

Generate a complete, deployable landing page from a brief. Produces a single self-contained HTML file with Tailwind CSS (via CDN), responsive design, dark mode, semantic HTML, and OG meta tags. Sections: hero with CTA, features, social proof, pricing (optional), FAQ, footer. Use when building a marketing page, product launch page, coming soon page, or any standalone landing page. Triggers: 'landing page', 'create a page', 'marketing page', 'launch page', 'coming soon page', 'one-page site'.

jezweb/cloudflare-worker-builder

Scaffold and deploy Cloudflare Workers with Hono routing, Vite plugin, and Static Assets. Describe project, scaffold structure, configure bindings, deploy. Use whenever the user wants to create a Worker project, set up Hono on Cloudflare, configure D1 / R2 / KV / Queues bindings, or troubleshoot Worker export syntax, API route conflicts, HMR issues, or deployment failures.

jezweb/color-palette

Generate complete, accessible colour palettes from a single brand hex. Produces 11-shade scale (50-950), semantic tokens, dark mode variants, Tailwind v4 CSS output, WCAG contrast checks. Use whenever the user supplies a brand hex and asks for a palette, mentions setting up a design system, wants Tailwind theme colours from a brand colour, or asks to check colour accessibility / contrast.

jezweb/d1-drizzle-schema

Generate Drizzle ORM schemas for Cloudflare D1 databases with correct D1-specific patterns. Produces schema files, migration commands, type exports, and DATABASE_SCHEMA.md documentation. Handles D1 quirks: foreign keys always enforced, no native BOOLEAN/DATETIME types, 100 bound parameter limit, JSON stored as TEXT. Use when creating a new database, adding tables, or scaffolding a D1 data layer.

jezweb/elevenlabs-agents

Build conversational AI voice agents on the ElevenLabs platform. Configure agent + tools + knowledge base, integrate SDK (React / React Native / Swift / JS / server-side), test, deploy. Use whenever the user mentions ElevenLabs, building a voice agent, an AI phone system, an AI receptionist, conversational AI, or troubleshooting deprecated @11labs packages, webhook errors, CSP violations, localhost allowlist, or tool parsing errors.

jezweb/fastapi

Build Python APIs with FastAPI, Pydantic v2, and SQLAlchemy 2.0 async. Covers project structure, JWT auth, validation, and database integration with uv package manager. Prevents 7 documented errors. Use when: creating Python APIs, implementing JWT auth, or troubleshooting 422 validation, CORS, async blocking, form data, background tasks, or OpenAPI schema errors.

jezweb/favicon-gen

Generate custom favicons from logos, text, or brand colours. Produces favicon.svg, favicon.ico, apple-touch-icon.png, icon-192/512.png, and web manifest. Use whenever the user wants a favicon, mentions replacing a CMS default favicon, converting a logo into a favicon, creating branded initials icons, or troubleshooting favicon not displaying / iOS black square / missing manifest.

jezweb/github-release

Prepare and publish GitHub releases. Sanitizes code for public release (secrets scan, personal artifacts, LICENSE/README validation), creates version tags, and publishes via gh CLI. Trigger with 'release', 'publish', 'open source', 'prepare for release', 'create release', or 'github release'.

jezweb/google-apps-script

Build Google Apps Script automation for Sheets and Workspace. Custom menus, triggers (onEdit / time-driven / form submit), dialogs, sidebars, email batches, PDF export, external API. Use whenever the user wants to automate a Google Sheet, build a Sheets menu / sidebar / dialog, hit a Sheets row from email or a webhook, schedule a Sheets workflow, or asks 'how do I script this in Sheets'.

jezweb/google-chat-messages

Send Google Chat messages via incoming webhooks — text, rich cards (cardsV2), threaded replies. TypeScript types, card builder utility, widget reference inline. Use whenever the user wants to post to Google Chat from a script, build a chatbot reply, send a notification card, build a Google Chat webhook integration, or troubleshoot card / threading issues.

jezweb/hono-api-scaffolder

Scaffold Hono API routes for Cloudflare Workers. Produces route files, middleware, typed bindings, Zod validation, error handling, and API_ENDPOINTS.md documentation. Use after a project is set up with cloudflare-worker-builder or vite-flare-starter, when you need to add API routes, create endpoints, or generate API documentation.

jezweb/icon-set-generator

Generate cohesive, project-specific SVG icon sets for websites and applications. Use this skill whenever the user needs custom icons, an icon set for a website or app, icons for a client project, or mentions needing SVG icons that look consistent together. Also trigger when the user describes a project and icons would naturally be part of the deliverable — e.g. 'I'm building a site for a plumber' implies they'll need service icons. Trigger on: 'icons for', 'icon set', 'custom icons', 'SVG icons', 'make me icons', 'I need icons', 'website icons', 'project icons', or any request for consistent visual assets for a web project. Produces individual SVG files with a consistent style engine, not generic icon library lookups.

jezweb/image-processing

Process images for web development — resize, crop, trim whitespace, convert formats (PNG/WebP/JPG), optimise file size, generate thumbnails, create OG card images. Uses Pillow (Python) — no ImageMagick needed. Trigger with 'resize image', 'convert to webp', 'trim logo', 'optimise images', 'make thumbnail', 'create OG image', 'crop whitespace', 'process image', or 'image too large'.

jezweb/mcp-builder

Build MCP servers in Python with FastMCP. Define tools / resources / prompts, build the server, test locally, deploy to FastMCP Cloud or Docker. Use whenever the user mentions building an MCP server, exposing tools to LLMs, FastMCP, building a Claude integration, or troubleshooting FastMCP module-level server, storage, lifespan, middleware, OAuth, or deployment errors.

jezweb/nextjs

Build Next.js 16 apps with App Router, Server Components/Actions, Cache Components ("use cache"), and async route params. Includes proxy.ts and React 19.2. Prevents 25 documented errors. Use when: building Next.js 16 projects, or troubleshooting async params (Promise types), "use cache" directives, parallel route 404s, Turbopack issues, i18n caching, navigation throttling.

jezweb/project-health

All-in-one project configuration and health management. Sets up new projects (settings.local.json, CLAUDE.md, .gitignore), audits existing projects (permissions, context quality, MCP coverage, leaked secrets, stale docs), tidies accumulated cruft, captures session learnings, and adds permission presets. Uses sub-agents for heavy analysis to keep main context clean. Trigger with 'project health', 'check project', 'setup project', 'kickoff', 'bootstrap', 'tidy permissions', 'clean settings', 'capture learnings', 'audit context', 'add python permissions', or 'init project'.

相关技能