[ PROMPT_NODE_28010 ]
Shadcn 命令行工具
[ SKILL_DOCUMENTATION ]
# shadcn CLI 参考
配置从 `components.json` 读取。
> **重要:** 始终使用项目的包运行器运行命令:`npx shadcn@latest`、`pnpm dlx shadcn@latest` 或 `bunx --bun shadcn@latest`。检查项目上下文中的 `packageManager` 以选择正确的一个。以下示例使用 `npx shadcn@latest`,请根据项目替换为正确的运行器。
> **重要:** 仅使用下文记录的标志。不要发明或猜测标志 — 如果标志未在此列出,则它不存在。CLI 会自动从项目的锁文件检测包管理器;不存在 `--package-manager` 标志。
## 内容
- 命令:init, add (dry-run, smart merge), search, view, docs, info, build
- 模板:next, vite, start, react-router, astro
- 预设:命名、代码、URL 格式和字段
- 切换预设
---
## 命令
### `init` — 初始化或创建项目
bash
npx shadcn@latest init [components...] [options]
在现有项目中初始化 shadcn/ui 或创建一个新项目(提供 `--name` 时)。可选择在同一步骤中安装组件。
| 标志 | 简写 | 描述 | 默认值 |
| ----------------------- | ----- | --------------------------------------------------------- | ------- |
| `--template ` | `-t` | 模板 (next, start, vite, next-monorepo, react-router) | — |
| `--preset [name]` | `-p` | 预设配置 (named, code, 或 URL) | — |
| `--yes` | `-y` | 跳过确认提示 | `true` |
| `--defaults` | `-d` | 使用默认值 (`--template=next --preset=base-nova`) | `false` |
| `--force` | `-f` | 强制覆盖现有配置 | `false` |
| `--cwd ` | `-c` | 工作目录 | 当前 |
| `--name ` | `-n` | 新项目名称 | — |
| `--silent` | `-s` | 静默输出 | `false` |
| `--rtl` | | 启用 RTL 支持 | — |
| `--reinstall` | | 重新安装现有 UI 组件 | `false` |
| `--monorepo` | | 构建 monorepo 项目 | — |
| `--no-monore`