CLI
We rely on shadcn
CLI to add components and blocks to your project.
The CLI provides an easy, interactive way to add components, blocks and pages to your project. Installing components using the CLI ensures that you have the latest version of the component and its dependencies.
init
command
You can use the init
command to initialize configuration and dependencies for a new project.
The init
command installs dependencies, adds the cn
util and configures CSS variables for the project.
pnpm dlx shadcn@latest init
npx shadcn@latest init
bun x --bun shadcn@latest init
You will be asked a few questions to initialize the project.
add
command
You can use the add
command to add components, blocks and pages to your project.
The add
command installs dependencies, adds the component, block or page to your project and updates the configuration.
pnpm dlx shadcn@latest add https://unlogg.com/r/product-card-01-block.json
npx shadcn@latest add https://unlogg.com/r/product-card-01-block.json
bun x --bun shadcn@latest add https://unlogg.com/r/product-card-01-block.json
You can use the same command to add shadcn/ui components.
To see a list of all available options, please refer to the shadcn/ui documentation.
Monorepo support
If you need to install the components in a monorepo, you can use the optional -c
flag.
This will allow you to specify the path to the project where you want to install the component.
pnpm dlx shadcn@latest add https://unlogg.com/r/product-card-01-block.json -c ./apps/www
npx shadcn@latest add https://unlogg.com/r/product-card-01-block.json -c ./apps/www
bun x --bun shadcn@latest add https://unlogg.com/r/product-card-01-block.json -c ./apps/www
Read more about monorepo support using the shadcn
CLI in the shadcn/ui documentation.