Loading...
Loading...
Compare original and translation side by side
IMPORTANT: Run all CLI commands using the project's package runner:,npx shadcn@latest, orpnpm dlx shadcn@latest— based on the project'sbunx --bun shadcn@latest. Examples below usepackageManagerbut substitute the correct runner for the project.npx shadcn@latest
重要提示: 请根据项目的使用对应的包运行器执行所有CLI命令:packageManager、npx shadcn@latest或pnpm dlx shadcn@latest。以下示例使用bunx --bun shadcn@latest,请根据项目实际情况替换为正确的运行器。npx shadcn@latest
!`npx shadcn@latest info --json 2>/dev/null || echo '{"error": "No shadcn project found. Run shadcn init first."}'`npx shadcn@latest docs <component>!`npx shadcn@latest info --json 2>/dev/null || echo '{"error": "No shadcn project found. Run shadcn init first."}'`npx shadcn@latest docs <component>npx shadcn@latest searchvariant="outline"size="sm"bg-primarytext-muted-foregroundbg-blue-500npx shadcn@latest searchvariant="outline"size="sm"bg-primarytext-muted-foregroundbg-blue-500classNamespace-x-*space-y-*flexgap-*flex flex-col gap-*size-*size-10w-10 h-10truncateoverflow-hidden text-ellipsis whitespace-nowrapdark:bg-backgroundtext-muted-foregroundcn()z-indexclassNamespace-x-*space-y-*gap-*flexflex flex-col gap-*size-*size-10w-10 h-10truncateoverflow-hidden text-ellipsis whitespace-nowrapdark:bg-backgroundtext-muted-foregroundcn()z-indexFieldGroupFielddivspace-y-*grid gap-*InputGroupInputGroupInputInputGroupTextareaInputTextareaInputGroupInputGroupInputGroupAddonToggleGroupButtonFieldSetFieldLegenddivdata-invalidaria-invaliddata-invalidFieldaria-invaliddata-disabledFielddisabledFieldGroupFieldspace-y-*grid gap-*divInputGroupInputGroupInputInputGroupTextareaInputGroupInputTextareaInputGroupInputGroupAddonToggleGroupButtonFieldSetFieldLegenddivdata-invalidaria-invalidFielddata-invalidaria-invalidFielddata-disableddisabledSelectItemSelectGroupDropdownMenuItemDropdownMenuGroupCommandItemCommandGroupasChildrenderbasenpx shadcn@latest infoDialogTitleSheetTitleDrawerTitleclassName="sr-only"CardHeaderCardTitleCardDescriptionCardContentCardFooterCardContentisPendingisLoadingSpinnerdata-icondisabledTabsTriggerTabsListTabsAvatarAvatarFallbackSelectItemSelectGroupDropdownMenuItemDropdownMenuGroupCommandItemCommandGroupasChildrendernpx shadcn@latest infobaseDialogTitleSheetTitleDrawerTitleclassName="sr-only"CardHeaderCardTitleCardDescriptionCardContentCardFooterCardContentisPendingisLoadingSpinnerdata-icondisabledTabsTriggerTabsListTabsAvatarAvatarFallbackdivAlertEmptysonnertoast()sonnerSeparator<hr><div className="border-t">Skeletonanimate-pulseBadgedivAlertEmptysonnersonnertoast()Separator<hr><div className="border-t">Skeletonanimate-pulseBadgeButtondata-icondata-icon="inline-start"data-icon="inline-end"size-4w-4 h-4icon={CheckIcon}Buttondata-icondata-icon="inline-start"data-icon="inline-end"size-4w-4 h-4icon={CheckIcon}npx shadcn@latest init --preset <code>npx shadcn@latest init --preset <code>// Form layout: FieldGroup + Field, not div + Label.
<FieldGroup>
<Field>
<FieldLabel htmlFor="email">Email</FieldLabel>
<Input id="email" />
</Field>
</FieldGroup>
// Validation: data-invalid on Field, aria-invalid on the control.
<Field data-invalid>
<FieldLabel>Email</FieldLabel>
<Input aria-invalid />
<FieldDescription>Invalid email.</FieldDescription>
</Field>
// Icons in buttons: data-icon, no sizing classes.
<Button>
<SearchIcon data-icon="inline-start" />
Search
</Button>
// Spacing: gap-*, not space-y-*.
<div className="flex flex-col gap-4"> // correct
<div className="space-y-4"> // wrong
// Equal dimensions: size-*, not w-* h-*.
<Avatar className="size-10"> // correct
<Avatar className="w-10 h-10"> // wrong
// Status colors: Badge variants or semantic tokens, not raw colors.
<Badge variant="secondary">+20.1%</Badge> // correct
<span className="text-emerald-600">+20.1%</span> // wrong// 表单布局:FieldGroup + Field,不要用div + Label
<FieldGroup>
<Field>
<FieldLabel htmlFor="email">Email</FieldLabel>
<Input id="email" />
</Field>
</FieldGroup>
// 校验:Field上添加data-invalid,控件上添加aria-invalid
<Field data-invalid>
<FieldLabel>Email</FieldLabel>
<Input aria-invalid />
<FieldDescription>Invalid email.</FieldDescription>
</Field>
// 按钮内的图标:添加data-icon,不要加尺寸类
<Button>
<SearchIcon data-icon="inline-start" />
Search
</Button>
// 间距:用gap-*,不要用space-y-*
<div className="flex flex-col gap-4"> // 正确
<div className="space-y-4"> // 错误
// 等宽高:用size-*,不要用w-* h-*
<Avatar className="size-10"> // 正确
<Avatar className="w-10 h-10"> // 错误
// 状态颜色:用Badge变体或语义化token,不要用原始颜色
<Badge variant="secondary">+20.1%</Badge> // 正确
<span className="text-emerald-600">+20.1%</span> // 错误| Need | Use |
|---|---|
| Button/action | |
| Form inputs | |
| Toggle between 2–5 options | |
| Data display | |
| Navigation | |
| Overlays | |
| Feedback | |
| Command palette | |
| Charts | |
| Layout | |
| Empty states | |
| Menus | |
| Tooltips/info | |
| 需求 | 推荐组件 |
|---|---|
| 按钮/操作按钮 | 对应变体的 |
| 表单输入 | |
| 2-5个选项的切换 | |
| 数据展示 | |
| 导航 | |
| 浮层 | |
| 反馈提示 | |
| 命令面板 | |
| 图表 | 封装了Recharts的 |
| 布局 | |
| 空状态 | |
| 菜单 | |
| 提示/信息展示 | |
aliases@/~/isRSCtrueuseStateuseEffect"use client"tailwindVersion"v4"@theme inline"v3"tailwind.config.jstailwindCssFilestylenovavegabaseradixbaseiconLibrarylucide-reactlucide@tabler/icons-reacttablerlucide-reactresolvedPathsframeworkpackageManagerpnpm add date-fnsnpm install date-fnsinfoaliases@/~/isRSCtrueuseStateuseEffect"use client"tailwindVersion"v4"@theme inline"v3"tailwind.config.jstailwindCssFilestylenovavegabaseradixbaseiconLibrarylucidelucide-reacttabler@tabler/icons-reactlucide-reactresolvedPathsframeworkpackageManagerpnpm add date-fnsnpm install date-fnsinfonpx shadcn@latest docs <component>npx shadcn@latest docs button dialog selectnpx shadcn@latest docsnpx shadcn@latest docs <component>npx shadcn@latest docs button dialog selectnpx shadcn@latest docsnpx shadcn@latest infoaddcomponentsresolvedPaths.uinpx shadcn@latest searchnpx shadcn@latest docs <component>npx shadcn@latest viewnpx shadcn@latest add --diffnpx shadcn@latest add--dry-run--diff@bundui@magicui@/components/ui/...npx shadcn@latest infoui@workspace/ui/componentsSelectItemSelectGroupiconLibrarylucide-reacthugeicons@shadcn@tailarknpx shadcn@latest init --preset <code> --force --reinstallnpx shadcn@latest init --preset <code> --force --no-reinstallnpx shadcn@latest info--dry-run--diffnpx shadcn@latest init --preset <code> --force --no-reinstallnpx shadcn@latest infoaddcomponentsresolvedPaths.uinpx shadcn@latest searchnpx shadcn@latest docs <component>npx shadcn@latest viewnpx shadcn@latest add --diffnpx shadcn@latest add--dry-run--diff@bundui@magicui@/components/ui/...npx shadcn@latest infoui@workspace/ui/componentsSelectGroupSelectItemiconLibrarylucide-reacthugeicons@shadcn@tailarknpx shadcn@latest init --preset <code> --force --reinstallnpx shadcn@latest init --preset <code> --force --no-reinstallnpx shadcn@latest info--dry-run--diffnpx shadcn@latest init --preset <code> --force --no-reinstall--dry-run--diffnpx shadcn@latest add <component> --dry-runnpx shadcn@latest add <component> --diff <file>--overwrite--overwrite--dry-run--diffnpx shadcn@latest add <component> --dry-runnpx shadcn@latest add <component> --diff <file>--overwrite--overwriteundefinedundefined
**Named presets:** `base-nova`, `radix-nova`
**Templates:** `next`, `vite`, `start`, `react-router`, `astro` (all support `--monorepo`) and `laravel` (not supported for monorepo)
**Preset codes:** Base62 strings starting with `a` (e.g. `a2r6bw`), from [ui.shadcn.com](https://ui.shadcn.com).
**命名预设:** `base-nova`、`radix-nova`
**模板:** `next`、`vite`、`start`、`react-router`、`astro`(均支持`--monorepo`)和`laravel`(不支持monorepo)
**预设代码:** 以`a`开头的Base62字符串(例如`a2r6bw`),来自[ui.shadcn.com](https://ui.shadcn.com)。