mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-23 12:45:47 +00:00
* chore: 2.2.0-canary.2 * feat: add docs for registry * docs(www): update registry docs * fix: update dep * docs(www): update docs * docs(www): update registry docs * feat: add new label * fix: lint
123 lines
3.1 KiB
Plaintext
123 lines
3.1 KiB
Plaintext
---
|
||
title: CLI
|
||
description: Use the CLI to add components to your project.
|
||
---
|
||
|
||
<Callout>
|
||
|
||
**Note:** We just released a new `shadcn` CLI. See the [changelog](/docs/changelog) for more information.
|
||
|
||
</Callout>
|
||
|
||
## init
|
||
|
||
Use the `init` command to initialize configuration and dependencies for a new project.
|
||
|
||
The `init` command installs dependencies, adds the `cn` util, configures `tailwind.config.js`, and CSS variables for the project.
|
||
|
||
```bash
|
||
npx shadcn@latest init
|
||
```
|
||
|
||
You will be asked a few questions to configure `components.json`:
|
||
|
||
```txt showLineNumbers
|
||
Which style would you like to use? › New York
|
||
Which color would you like to use as base color? › Zinc
|
||
Do you want to use CSS variables for colors? › no / yes
|
||
```
|
||
|
||
### Options
|
||
|
||
```txt
|
||
Usage: shadcn init [options] [components...]
|
||
|
||
initialize your project and install dependencies
|
||
|
||
Arguments:
|
||
components the components to add or a url to the component.
|
||
|
||
Options:
|
||
-d, --defaults use default values i.e new-york, zinc and css variables. (default: false)
|
||
-f, --force force overwrite of existing components.json. (default: false)
|
||
-y, --yes skip confirmation prompt. (default: false)
|
||
-c, --cwd <cwd> the working directory. defaults to the current directory.
|
||
-h, --help display help for command
|
||
```
|
||
|
||
## add
|
||
|
||
Use the `add` command to add components and dependencies to your project.
|
||
|
||
```bash
|
||
npx shadcn@latest add [component]
|
||
```
|
||
|
||
You will be presented with a list of components to choose from:
|
||
|
||
```txt
|
||
Which components would you like to add? › Space to select. A to toggle all.
|
||
Enter to submit.
|
||
|
||
◯ accordion
|
||
◯ alert
|
||
◯ alert-dialog
|
||
◯ aspect-ratio
|
||
◯ avatar
|
||
◯ badge
|
||
◯ button
|
||
◯ calendar
|
||
◯ card
|
||
◯ checkbox
|
||
```
|
||
|
||
### Options
|
||
|
||
```txt
|
||
Usage: shadcn add [options] [components...]
|
||
|
||
add a component to your project
|
||
|
||
Arguments:
|
||
components the components to add or a url to the component.
|
||
|
||
Options:
|
||
-y, --yes skip confirmation prompt. (default: false)
|
||
-o, --overwrite overwrite existing files. (default: false)
|
||
-c, --cwd <cwd> the working directory. defaults to the current directory.
|
||
-a, --all add all available components. (default: false)
|
||
-p, --path <path> the path to add the component to.
|
||
-h, --help display help for command
|
||
```
|
||
|
||
## build
|
||
|
||
Use the `build` command to generate the registry JSON files.
|
||
|
||
```bash
|
||
npx shadcn@latest build
|
||
```
|
||
|
||
This command reads the `registry.json` file and generates the registry JSON files in the `public/r` directory.
|
||
|
||
```txt
|
||
Usage: shadcn build [options] [registry]
|
||
|
||
build components for a shadcn registry
|
||
|
||
Arguments:
|
||
registry path to registry.json file (default: "./registry.json")
|
||
|
||
Options:
|
||
-o, --output <path> destination directory for json files (default: "./public/r")
|
||
-c, --cwd <cwd> the working directory. defaults to the current directory. (default:
|
||
"/Users/shadcn/Code/shadcn/ui/packages/shadcn")
|
||
-h, --help display help for command
|
||
```
|
||
|
||
To customize the output directory, use the `--output` option.
|
||
|
||
```bash
|
||
npx shadcn@latest build --output ./public/registry
|
||
```
|