AgentSkillsCN

shadcn-components

在创建新组件时,优先选用ShadCN UI。在构建之前,务必通过npm CLI添加ShadCN基础组件。在创建UI组件、表单、对话框、按钮、输入框,或任何需要样式的React组件时使用。

SKILL.md
--- frontmatter
name: shadcn-components
description: Use ShadCN UI when creating new components. Always add ShadCN primitives via the npm CLI before building. Use when creating UI components, forms, dialogs, buttons, inputs, or any React component that needs styling.

ShadCN Component Workflow

When creating new UI components, use ShadCN UI as the component library. Never manually copy ShadCN component code—always install via the CLI.

Workflow

  1. Identify needed ShadCN primitives from ui.shadcn.com/docs/components
  2. Install via CLI before writing component code:
bash
npx shadcn@latest add <component-name>

Add multiple components in one command:

bash
npx shadcn@latest add button input label
  1. Import from the project alias (configured in components.json):
tsx
import { Button } from "~/components/ui/button";
import { Input } from "~/components/ui/input";
  1. Build your component using the installed primitives. Use the cn() utility for merging class names:
tsx
import { cn } from "~/lib/utils";

Common Component Mappings

NeedShadCN component
Button, link-as-buttonbutton
Text input, form fieldinput, label
Card layoutcard
Modal/dialogdialog
Dropdown menudropdown-menu
Form with validationform (includes react-hook-form)
Tabstabs
Toast notificationssonner or toast
Select/pickerselect
Checkbox, switchcheckbox, switch

Rules

  • Always run npx shadcn@latest add <component> before using a ShadCN component in code
  • Use ~/components/ui/<component> import path (React Router / project alias)
  • Use cn() from ~/lib/utils for conditional class merging
  • Check components.json for project-specific aliases if imports fail