shadcn
Original:🇺🇸 English
Not Translated
shadcn/ui expert guidance — CLI, component installation, composition patterns, custom registries, theming, Tailwind CSS integration, and high-quality interface design. Use when initializing shadcn, adding components, composing product UI, building custom registries, configuring themes, or troubleshooting component issues.
4installs
Sourcevercel/vercel-plugin
Added on
NPX Install
npx skill4agent add vercel/vercel-plugin shadcnSKILL.md Content
shadcn/ui
You are an expert in shadcn/ui — a collection of beautifully designed, accessible, and customizable React components built on Radix UI primitives and Tailwind CSS. Components are added directly to your codebase as source code, not installed as a dependency.
Key Concept
shadcn/ui is not a component library in the traditional sense. You don't install it as a package. Instead, the CLI copies component source code into your project, giving you full ownership and customization ability.
CLI Commands
Initialize (non-interactive — ALWAYS use this)
IMPORTANT: is interactive by default. Always use (defaults) for non-interactive initialization:
shadcn init-dbash
# Non-interactive init with defaults — USE THIS
npx shadcn@latest init -d
# Non-interactive with a preset (recommended for consistent design systems)
npx shadcn@latest init --preset <code> -f
# Non-interactive with explicit base library choice
npx shadcn@latest init -d --base radix
npx shadcn@latest init -d --base base-ui
# Scaffold a full project template (CLI v4)AI Elements compatibility: Always use(the default) when the project uses or may use AI Elements. AI Elements components rely on Radix APIs and have type errors with Base UI.--base radix
bash
npx shadcn@latest init --template next -d
npx shadcn@latest init --template vite -dOptions:
- — Use default configuration, skip all interactive prompts (REQUIRED for CI/agent use)
-d, --defaults - — Skip confirmation prompts (does NOT skip library selection — use
-y, --yesinstead)-d - — Force overwrite existing configuration
-f, --force - — Scaffold full project template (
-t, --template,next,vite,react-router,astro,laravel)tanstack-start - — Apply a design system preset (colors, theme, icons, fonts, radius) as a single shareable code
--preset - — Choose primitive library:
--base(default) orradixbase-ui - — Set up a monorepo structure
--monorepo
WARNING:/-yalone does NOT make init fully non-interactive — it still prompts for component library selection. Always use--yesto skip ALL prompts.-d
Deprecated in CLI v4:,--style,--base-color,--src-dir, and--no-base-styleflags are removed and will error. The--css-variablesandregistry:buildregistry types are also deprecated. Useregistry:mcpandregistry:baseinstead.registry:font
The init command:
- Detects your framework (Next.js, Vite, React Router, Astro, Laravel, TanStack Start)
- Installs required dependencies (Radix UI, tailwind-merge, class-variance-authority)
- Creates configuration
components.json - Sets up the utility function
cn() - Configures CSS variables for theming
Add Components
bash
# Add specific components
npx shadcn@latest add button dialog card
# Add all available components
npx shadcn@latest add --all
# Add from a custom registry
npx shadcn@latest add @v0/dashboard
npx shadcn@latest add @acme/custom-button
# Add from AI Elements registry
npx shadcn@latest add https://elements.ai-sdk.dev/api/registry/all.jsonOptions:
- — Overwrite existing files
-o, --overwrite - — Custom install path
-p, --path - — Install all components
-a, --all - — Preview what will be added without writing files
--dry-run - — Show diff of changes when updating existing components
--diff - — Display a registry item's source code inline
--view
Search & List
bash
npx shadcn@latest search button
npx shadcn@latest list @v0Build (Custom Registry)
bash
npx shadcn@latest build
npx shadcn@latest build ./registry.json -o ./public/rView, Info & Docs (CLI v4)
bash
# View a registry item's source before installing
npx shadcn@latest view button
# Show project diagnostics — config, installed components, dependencies
npx shadcn@latest info
# Get docs, code, and examples for any component (agent-friendly output)
npx shadcn@latest docs button
npx shadcn@latest docs dialoggives coding agents the context to use primitives correctly — returns code examples, API reference, and usage patterns inline.shadcn docs
Migrate
bash
npx shadcn@latest migrate rtl # RTL support migration
npx shadcn@latest migrate radix # Migrate to unified radix-ui package
npx shadcn@latest migrate icons # Icon library changes
# Migrate components outside the default ui directory
npx shadcn@latest migrate radix src/components/customshadcn/skills (CLI v4)
shadcn/skills gives coding agents the context they need to work with components and registries correctly. It covers both Radix and Base UI primitives, updated APIs, component patterns, and registry workflows. The skill knows how to use the CLI, when to invoke it, and which flags to pass — so agents produce code that matches your design system.
Install:
pnpm dlx skills add shadcn/uiUnified Radix UI Package (February 2026)
The style now uses a single package instead of individual packages:
new-yorkradix-ui@radix-ui/react-*tsx
// OLD — individual packages
import * as DialogPrimitive from "@radix-ui/react-dialog"
// NEW — unified package
import { Dialog as DialogPrimitive } from "radix-ui"To migrate existing projects: . After migration, remove unused packages from .
npx shadcn@latest migrate radix@radix-ui/react-*package.jsonBase UI Support (January 2026)
shadcn/ui now supports Base UI as an alternative to Radix UI for the underlying primitive library. Components look and behave the same way regardless of which library you choose — only the underlying implementation changes.
Choose during init:
npx shadcn@latest init --base base-uiThe CLI pulls the correct component variant based on your project configuration automatically.
Configuration (components.json)
The file configures how shadcn/ui works in your project:
components.jsonjson
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "new-york",
"rsc": true,
"tsx": true,
"tailwind": {
"config": "tailwind.config.ts",
"css": "src/app/globals.css",
"baseColor": "zinc", // Options: gray, neutral, slate, stone, zinc, mauve, olive, mist, taupe
"cssVariables": true
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils",
"ui": "@/components/ui",
"lib": "@/lib",
"hooks": "@/hooks"
},
"registries": {
"v0": {
"url": "https://v0.dev/chat/api/registry"
},
"ai-elements": {
"url": "https://elements.ai-sdk.dev/api/registry"
}
}
}Namespaced Registries
Configure multiple registries for your project:
json
{
"registries": {
"acme": {
"url": "https://acme.com/registry/{name}.json"
},
"private": {
"url": "https://internal.company.com/registry/{name}.json",
"headers": {
"Authorization": "Bearer ${REGISTRY_TOKEN}"
}
}
}
}Install using namespace syntax:
bash
npx shadcn@latest add @acme/header @private/auth-formTheming
CSS Variables
shadcn/ui uses CSS custom properties for theming, defined in :
globals.csscss
@theme inline {
--color-background: oklch(0.145 0 0);
--color-foreground: oklch(0.985 0 0);
--color-card: oklch(0.205 0 0);
--color-card-foreground: oklch(0.985 0 0);
--color-primary: oklch(0.488 0.243 264.376);
--color-primary-foreground: oklch(0.985 0 0);
--color-secondary: oklch(0.269 0 0);
--color-secondary-foreground: oklch(0.985 0 0);
--color-muted: oklch(0.269 0 0);
--color-muted-foreground: oklch(0.708 0 0);
--color-accent: oklch(0.269 0 0);
--color-accent-foreground: oklch(0.985 0 0);
--color-destructive: oklch(0.396 0.141 25.723);
--color-border: oklch(0.269 0 0);
--color-input: oklch(0.269 0 0);
--color-ring: oklch(0.488 0.243 264.376);
--radius: 0.625rem;
/* CLI v4: radius tokens use multiplicative calc instead of additive */
--radius-xs: calc(var(--radius) * 0.5);
--radius-sm: calc(var(--radius) * 0.75);
--radius-md: calc(var(--radius) * 0.875);
--radius-lg: var(--radius);
--radius-xl: calc(var(--radius) * 1.5);
}Dark Mode
For dark mode, use the class on :
dark<html>tsx
// app/layout.tsx
<html lang="en" className="dark">Or use next-themes for toggling:
tsx
import { ThemeProvider } from 'next-themes'
<ThemeProvider attribute="class" defaultTheme="dark">
{children}
</ThemeProvider>Custom Colors
Add application-specific colors alongside shadcn defaults:
css
@theme inline {
/* shadcn defaults above... */
/* Custom app colors */
--color-priority-urgent: oklch(0.637 0.237 15.163);
--color-priority-high: oklch(0.705 0.213 47.604);
--color-status-done: oklch(0.723 0.219 149.579);
}Use in components:
tsx
<span className="text-[var(--color-priority-urgent)]">Urgent</span>
// Or with Tailwind v4 theme():
<span className="text-priority-urgent">Urgent</span>Most Common Components
| Component | Use Case |
|---|---|
| Actions, form submission |
| Content containers |
| Modals, confirmation prompts |
| Form fields |
| Dropdowns |
| Data display |
| View switching |
| Command palette (Cmd+K) |
| Context menus |
| Floating content |
| Hover hints |
| Status indicators |
| User profile images |
| Scrollable containers |
| Visual dividers |
| Form labels |
| Slide-out panels |
| Loading placeholders |
Design Direction for shadcn on Vercel
shadcn/ui is not only a component source generator. In the Vercel stack it is the default interface language. Do not stop at "the component works." Compose pages that feel deliberate, high-signal, and consistent.
Default aesthetic for product UI
- Prefer style: for product, dashboard, AI, and admin surfaces.
new-york - Default to dark mode for dashboards, AI apps, internal tools, settings, and developer-facing products. Use light mode only when the product is clearly content-first or editorial.
- Use Geist Sans for interface text and Geist Mono for code, metrics, IDs, timestamps, commands.
- Prefer zinc, neutral, or slate as the base palette. Use one accent color through .
--color-primary - Build core surfaces from tokens: ,
bg-background,bg-card,text-foreground,text-muted-foreground,border-border. Avoid ad-hoc hex values.ring-ring - Keep radius consistent. The default is a strong baseline.
--radius: 0.625rem - Use one density system per page: comfortable (/
gap-6/p-6) or compact (text-sm/gap-4/p-4).text-sm - Keep icons quiet and consistent. Lucide icons at or
h-4 w-4.h-5 w-5
Reach for this first
| Use case | Reach for this first | Why |
|---|---|---|
| Settings page | | Clear information grouping with predictable save flows |
| Data dashboard | | Covers summary, status, dense data, and row actions without custom shells |
| CRUD table | | Supports browse, act, edit, and destructive confirmation in a standard pattern |
| Auth screen | | Keeps entry flows focused and gives errors a proper treatment |
| Global search | | Fast keyboard-first discovery with an established interaction model |
| Mobile nav | | Provides a compact navigation shell that adapts cleanly to small screens |
| Detail page | header + | Balances hierarchy, metadata, and supporting content without over-nesting |
| Filters | | Works for persistent desktop filters and collapsible mobile controls |
| Empty/loading/error states | | Gives non-happy paths a designed surface instead of placeholder text |
Composition recipes
- Settings page: +
Tabsper group +Card+ save actionSeparator - Admin dashboard: summary s + filter bar +
CardTable - Entity detail: header + status + main
Badge+ sideCard+Cardfor destructiveAlertDialog - Search-heavy: for quick find,
Commandfor pickers,Popoverfor mobile filtersSheet - Auth/onboarding: centered + social
Card+ inlineSeparatorfor errorsAlert - Destructive flows: (not
AlertDialog) for confirmationDialog
Anti-patterns to avoid
- Raw /
button/input/selectwhen shadcn primitives existdiv - Repeated instead of
div rounded-xl border p-6/Tabs/Table/SheetDialog - Multiple accent colors fighting each other
- Nested cards inside cards inside cards
- Large gradient backgrounds and glassmorphism on every surface
- Mixing arbitrary spacing and radius values
- Using for destructive confirmation instead of
DialogAlertDialog - Shipping empty/loading/error states without design treatment
- Using ad-hoc Tailwind palette classes for foundational surfaces instead of theme tokens
Building a Custom Registry
Create your own component registry to share across projects:
Registry Types (CLI v4)
| Type | Purpose |
|---|---|
| Individual UI components |
| Full design system payload — components, deps, CSS vars, fonts, config |
| Font configuration as a first-class registry item |
1. Define registry.json
json
[
{
"name": "my-component",
"type": "registry:ui",
"title": "My Component",
"description": "A custom component",
"files": [
{
"path": "components/my-component.tsx",
"type": "registry:ui"
}
],
"dependencies": ["lucide-react"]
}
]2. Build
bash
npx shadcn@latest build
# Outputs to public/r/my-component.json3. Consume
bash
npx shadcn@latest add https://your-domain.com/r/my-component.jsonComponent Gotchas
shadcn init
Breaks Geist Font in Next.js (Tailwind v4)
shadcn initshadcn initglobals.css--font-sans: var(--font-sans)@theme inlinevar(--font-geist-sans)The fix: Use literal font family names in :
@theme inlinecss
/* In @theme inline — CORRECT (literal names) */
--font-sans: "Geist", "Geist Fallback", ui-sans-serif, system-ui, sans-serif;
--font-mono: "Geist Mono", "Geist Mono Fallback", ui-monospace, monospace;
/* WRONG — circular, resolves to nothing */
--font-sans: var(--font-sans);
/* ALSO WRONG — @theme inline can't resolve runtime CSS variables */
--font-sans: var(--font-geist-sans);After running , always:
shadcn init- Replace font declarations in with literal Geist font names (as shown above)
@theme inline - Move the font variable classNames from to
<body>in<html>:layout.tsx
tsx
// layout.tsx — font variables on <html>, not <body>
<html lang="en" className={`${geistSans.variable} ${geistMono.variable}`}>
<body className="antialiased">Avatar Has No size
Prop
sizeThe shadcn Avatar component does not accept a variant prop. Control size with Tailwind classes:
sizetsx
// WRONG — no size variant exists
<Avatar size="lg" /> // ❌ TypeScript error / silently ignored
// CORRECT — use Tailwind
<Avatar className="h-12 w-12">
<AvatarImage src={user.image} />
<AvatarFallback>JD</AvatarFallback>
</Avatar>
// Small avatar
<Avatar className="h-6 w-6"> ... </Avatar>This applies to most shadcn components — they use Tailwind classes for sizing, not variant props. If you need reusable size variants, add them yourself via in the component source.
cvaCommon Patterns
cn() Utility
All shadcn components use the utility for conditional class merging:
cn()ts
import { clsx, type ClassValue } from 'clsx'
import { twMerge } from 'tailwind-merge'
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}Extending Components
Since you own the source code, extend components directly:
tsx
// components/ui/button.tsx — add your custom variant
const buttonVariants = cva('...', {
variants: {
variant: {
default: '...',
destructive: '...',
// Add custom variants
success: 'bg-green-600 text-white hover:bg-green-700',
premium: 'bg-gradient-to-r from-purple-500 to-pink-500 text-white',
},
},
})Wrapping with TooltipProvider
Many components require at the root:
TooltipProvidertsx
// app/layout.tsx
import { TooltipProvider } from '@/components/ui/tooltip'
export default function RootLayout({ children }) {
return (
<html lang="en" className="dark">
<body>
<TooltipProvider>{children}</TooltipProvider>
</body>
</html>
)
}Framework Support
- Next.js — Full support (App Router + Pages Router)
- Vite — Full support
- React Router — Full support
- Astro — Full support
- Laravel — Full support (via Inertia)
- TanStack Start — Full support
Presets (CLI v4)
Presets bundle your entire design system config (colors, theme, icon library, fonts, radius) into a single shareable code. One string configures everything:
bash
# Apply a preset during init
npx shadcn@latest init --preset <code>
# Switch presets in an existing project (reconfigures everything including components)
npx shadcn@latest init --preset <code>Build custom presets on — preview how colors, fonts, and radius apply to real components before publishing.
shadcn/createRTL Support (2026)
The CLI handles RTL transformation at install time:
bash
npx shadcn@latest migrate rtlConverts directional classes (, ) to logical properties (, ) automatically.
ml-4left-2ms-4start-2