CLI
使用 CLI 将组件添加到您的项目中。
init
使用 init
命令为新项目初始化配置和依赖项。
init
命令将安装依赖项,添加 cn
、useEmitsAsProps
工具,配置 tailwind.config.cjs
,并为项目创建 CSS 变量。
bash
npx shadcn-vue@latest init
您将被询问一些问题以配置 components.json
txt
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
选项
txt
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
命令将组件和依赖项添加到您的项目中。
bash
npx shadcn-vue@latest add [component]
您将看到一个组件列表供您选择。
txt
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
选项
txt
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
命令更新项目中的组件。这将覆盖您对组件所做的任何修改,因此请确保在运行此命令之前提交您的更改。
我们计划在将来改进此命令以改善更新体验。
txt
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