菜单
本页目录

CLI

使用 命令行工具(CLI) 向你的项目添加组件

init

使用 init 命令初始化新项目的配置和依赖项。

init 命令会安装依赖项,添加 cnuseEmitsAsProps 工具,配置 tailwind.config.cjs,并为项目创建 CSS 变量。

npx shadcn-vue@latest init

您将被问到几个问题来配置 components.json:

Would you like to use TypeScript (recommended)? no / yes
Which framework are you using? Vite / Nuxt / Laravel
Which style would you like to use? › Default
Which color would you like to use as base color? › Slate
Where is your global CSS file? › › src/index.css
Do you want to use CSS variables for colors? › no / yes
Where is your tailwind.config.js located? › tailwind.config.js
Configure the import alias for components: › @/components
Configure the import alias for utils: › @/lib/utils

Options

Usage: shadcn-vue init [options]

initialize your project and install dependencies

Options:
  -y, --yes        skip confirmation prompt. (default: false)
  -c, --cwd <cwd>  the working directory. (default: the current directory)
  -h, --help       display help for command

add

使用 add 命令将组件和依赖项添加到您的项目中。

npx shadcn-vue@latest add [component]

你将看到一个可供选择的组件列表:

Which components would you like to add? › Space to select. Return to submit.

◯  accordion
◯  alert
◯  alert-dialog
◯  aspect-ratio
◯  avatar
◯  badge
◯  button
◯  card
◯  checkbox
◯  collapsible

Options

Usage: shadcn-vue add [options] [components...]

add components to your project

Arguments:
  components         name of components

Options:
  --nodep            disable adding & installing dependencies (advanced) (default: false)
  -y, --yes          Skip confirmation prompt. (default: false)
  -o, --overwrite    overwrite existing files. (default: false)
  -c, --cwd <cwd>    the working directory. (default: the current directory)
  -p, --path <path>  the path to add the component to.
  -h, --help         display help for command

update

使用 update 命令来更新您项目中的组件。这将覆盖您对组件所做的任何修改,因此在运行此命令之前,请确保提交你的更改。

我们计划在未来改进此命令,以提升更新体验。

Usage: shadcn-vue update [options] [components...]

update components in your project

Arguments:
  components       name of components

Options:
  -c, --cwd <cwd>  the working directory. (default: the current directory)
  -h, --help       display help for command