Capítulo 2 de 108
The shadcn CLI is the distribution mechanism: it initializes a project, adds components/dependencies, applies presets, inspects the registry, builds custom registries, and runs codemod-style migrations (icons, base color, RTL, radix imports).
--name); installs cn util and CSS variables.--only theme|font limits scope.decode, resolve/info, url, open to inspect/resolve preset codes.view previews registry items before installing; search/list queries registries (prefixed with @).registry.json and generates registry JSON files (default ./public/r) for custom/self-hosted registries.--base (base, radix, aria).icons, base-color, rtl, radix.shadcn/tailwind.css into your global CSS and removes the shadcn dependency (irreversible).npx shadcn@latest init
npx shadcn@latest add button card dialog
npx shadcn@latest add --all
npx shadcn@latest view @acme/auth @v0/dashboard
npx shadcn@latest search @shadcn -q "button"
npx shadcn@latest migrate icons --from lucide --to phosphor --yes
npx shadcn@latest migrate base-color --to zinc --yes
npx shadcn@latest migrate rtl "src/components/ui/**"
npx shadcn@latest migrate radix src/components/ui/dialog.tsx
npx shadcn@latest build --output ./public/registry
npx shadcn@latest eject
| Migration | Description |
|---|---|
icons | Migrate UI components to a different icon library (lucide, tabler, hugeicons, phosphor, remixicon, radix legacy). |
base-color | Migrate theme to a different base color (neutral, zinc, stone, mauve, olive, mist, taupe). |
radix | Migrate individual @radix-ui/react-* imports to the unified radix-ui package. |
rtl | Migrate physical CSS to logical (ml-4→ms-4) and add rtl: variants. |
init key options: -t/--template (next, vite, start, react-router, laravel, astro), -b/--base (base, radix, aria), -p/--preset, -d/--defaults (template=next, preset=nova), --css-variables/--no-css-variables, --monorepo, --rtl, --pointer, --reinstall.
add key options: -a/--all, -o/--overwrite, -p/--path, --dry-run, --diff, --view.
eject casually: it's irreversible; future CLI updates to shadcn/tailwind.css no longer apply automatically afterward.--from/--to in CI: non-interactive runs need these flags or the command will prompt and hang.components.json to update: only full-directory runs update components.json's iconLibrary/baseColor.add and init are the two commands used day-to-day; the rest (migrate, build, docs, search, preset) are situational.eject removes the shadcn npm dependency entirely by inlining its shared Tailwind utilities, a one-way door.build is for authoring/self-hosting your own component registry, not for consuming shadcn's.init/add read and write this config file.migrate base-color and CSS variables relate directly to the theming system.