Get started with shadcn CLI in minutes.
shadcn can be used directly with npx or installed as a dependency:
# Use directly (recommended)
npx shadcn init
# Or install globally
npm install -g shadcn
# Or install as project dependency
npm install shadcnInitialize a new project with shadcn/ui configuration:
npx shadcn initThis command:
components.json configuration filecn utility function for className mergingThe command will prompt you for:
Add components to your project:
# Add single component
npx shadcn add button
# Add multiple components
npx shadcn add button card dialog
# Non-interactive mode (for automation)
npx shadcn add button --yes --overwriteComponents are added to your project with:
Search for available components:
# List all components
npx shadcn search @shadcn
# Search with query
npx shadcn search @shadcn --query button
# Search multiple registries
npx shadcn search @shadcn @acmeView detailed information about components:
# View single component
npx shadcn view @shadcn/button
# View multiple components
npx shadcn view @shadcn/button @shadcn/cardUse the programmatic API in your code:
import { getRegistryItems, resolveRegistryItems } from 'shadcn';
// Fetch components
const items = await getRegistryItems(['@shadcn/button', '@shadcn/card']);
// Resolve with all dependencies
const resolved = await resolveRegistryItems(['@shadcn/button']);
console.log(resolved.dependencies); // npm dependencies
console.log(resolved.files); // component filesThe components.json file contains your project configuration:
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "new-york",
"rsc": false,
"tsx": true,
"tailwind": {
"config": "tailwind.config.js",
"css": "app/globals.css",
"baseColor": "slate",
"cssVariables": true
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils",
"ui": "@/components/ui"
},
"iconLibrary": "lucide",
"registries": {
"@shadcn": "https://ui.shadcn.com/r/{name}.json"
}
}