Documentation menu
Getting Started
Components
Primitives
- Agent Thinking
- Alert
- Alert Dialog
- Avatar
- Badge
- Breadcrumb
- Button
- Button Group
- Calendar
- Card
- Checkbox
- Command
- Command Palette
- Context Menu
- Data Table
- Dialog
- Dropdown Menu
- Empty
- Field
- Glow Cloud
- Input
- Label
- Medication Schedule
- Period Tabs
- Popover
- Rainbow Button
- Scroll Area
- Select
- Selectable Card
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner
- Spinner
- Switch
- Table
- Tabs
- Tag
- Textarea
- Timeline
- Tooltip
- Use Count Up
Charts and metrics
Patterns
- Confirm Button
- Date Picker
- Embedded
- Empty State
- Entity Drawer
- Error Boundary
- Field Row
- File Dropzone
- Form Dialog
- Kv
- List Editor
- List Page
- Live Time
- Mini Table
- Money
- Note Field
- Note Text
- Page Card
- Page Header
- Page Tabs
- Page Toolbar
- Person Cell
- Picture Field
- Print Card
- Range Switcher
- Row Actions
- Search Input
- Search Select
- Selected Box
- Signature Pad
- Status Badge
- Sub Nav Layout
- Suggest Input
- Tab Icons
- Table Footer
- Theme Accent Picker
- Time Picker
- View All Link
Dashboard cards
Advanced
Device frames
Website widgets
Website screens
Website panels
Registry
How it works
A registry is a folder of JSON files. The CLI turns them into source files in your project.
The pipeline
Source
src/registry/**
registry.json
manifest
shadcn build
inlines files
public/r/*.json
static host
shadcn add
in your app
Nothing runs at request time. The left half happens on your machine or in CI. The right half happens on your user's machine. In between is a CDN serving static files.
1. The manifest entry
Each component gets one entry in registry.json. This is the real entry for Button:
{
"name": "button",
"type": "registry:ui",
"title": "Button",
"description": "Displays a button or a component that looks like a button.",
"dependencies": ["class-variance-authority", "@radix-ui/react-slot"],
"registryDependencies": ["@vcare/utils"],
"files": [
{ "path": "src/registry/vcare/ui/button.tsx", "type": "registry:ui" }
]
}typedecides where the file lands.registry:uigoes to theuialias,registry:libtolib,registry:hooktohooks.dependenciesare npm packages the CLI installs with the user's package manager.registryDependenciesare other registry items, installed first. Here that is thecnhelper.files[].pathis where the build script reads the source from.
2. The built item
shadcn build reads each file and embeds its text in content, producing a self-contained document:
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "button",
"type": "registry:ui",
"dependencies": ["class-variance-authority", "@radix-ui/react-slot"],
"registryDependencies": ["@vcare/utils"],
"files": [
{
"path": "src/registry/vcare/ui/button.tsx",
"type": "registry:ui",
"content": "import * as React from \"react\"\n..." // the full source
}
]
}Open /r/button.json on this site to see the real thing.
3. The source file
The source is ordinary React. Note the import: it uses the registry's own path, @/registry/vcare/lib/utils.
src/registry/vcare/ui/button.tsx
import * as React from 'react';
import { cva, type VariantProps } from 'class-variance-authority';
import { cn } from '@/registry/vcare/lib/utils';
import { Slot } from 'radix-ui';
import type { RenderProp } from '@/registry/vcare/lib/render-compat';
const buttonVariants = cva(
"inline-flex shrink-0 cursor-pointer items-center justify-center gap-1.5 rounded-xl font-semibold leading-none whitespace-nowrap select-none outline-none transition-[scale,background-color,color,box-shadow,opacity] duration-150 ease-power3-out focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary dark:focus-visible:outline-foreground disabled:pointer-events-none disabled:opacity-50 aria-invalid:ring-2 aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
{
variants: {
variant: {
default: 'bg-primary text-primary-foreground shadow-primary hover:bg-primary-hover',
secondary: 'bg-secondary text-secondary-foreground shadow-raised ring-1 ring-inset ring-primary/40 hover:bg-primary/10 hover:ring-primary/70 [&_svg]:text-primary dark:ring-foreground/25 dark:hover:bg-primary/20 dark:hover:ring-foreground/45 dark:[&_svg]:text-foreground',
outline: 'bg-secondary text-secondary-foreground shadow-raised ring-1 ring-inset ring-primary/40 hover:bg-primary/10 hover:ring-primary/70 [&_svg]:text-primary dark:ring-foreground/25 dark:hover:bg-primary/20 dark:hover:ring-foreground/45 dark:[&_svg]:text-foreground',
destructive: 'bg-destructive text-background hover:bg-destructive/90',
ghost: 'text-foreground/80 hover:bg-accent hover:text-foreground',
link: 'rounded-none text-primary underline-offset-4 hover:underline',
},
size: {
default: 'h-control px-3.5 text-[13px]',
xs: "h-control-sm px-2 text-xs [&_svg:not([class*='size-'])]:size-3",
sm: 'h-control-sm px-3 text-xs',
lg: 'h-control-lg px-4 text-sm',
icon: 'size-(--control-h) p-0',
'icon-xs': 'size-(--control-h-sm) p-0',
'icon-sm': 'size-(--control-h-sm) p-0',
'icon-lg': 'size-(--control-h-lg) p-0',
},
},
// A ghost button with words is still an action: a soft tint of the brand colour so it never reads as plain text.
// Icon-only ghost buttons (toolbars, row actions) stay plain.
compoundVariants: [
{
variant: 'ghost',
size: ['default', 'xs', 'sm', 'lg'],
className: 'bg-primary/10 text-primary hover:bg-primary/15 hover:text-primary dark:bg-primary/30 dark:text-foreground dark:hover:bg-primary/45 dark:hover:text-foreground',
},
],
defaultVariants: { variant: 'default', size: 'default' },
},
);
function Button({
className,
variant = 'default',
size = 'default',
asChild = false,
static: isStatic = false,
render,
children,
...props
}: React.ComponentProps<'button'> &
RenderProp &
VariantProps<typeof buttonVariants> & {
asChild?: boolean;
/** Opt out of the press-scale feedback. */
static?: boolean;
}) {
const Comp = asChild || render ? Slot.Root : 'button';
const resolved = typeof render === 'function' ? render({}) : render;
const content = resolved
? React.cloneElement(resolved, undefined, children ?? (resolved.props as { children?: React.ReactNode }).children)
: children;
return (
<Comp
data-slot="button"
data-variant={variant}
data-size={size}
className={cn(buttonVariants({ variant, size }), !isStatic && 'active:not-disabled:scale-[0.96] motion-reduce:active:scale-100', className)}
{...props}
>
{content}
</Comp>
);
}
export { Button, buttonVariants };4. What add does
- Resolves the name or URL and downloads the item JSON.
- Walks
registryDependenciesrecursively and downloads those too. - Reads the user's
components.jsonandtsconfigfor aliases. - Rewrites imports.
@/registry/vcare/lib/utilsbecomes whatever the user'sutilsalias is, for instance@/lib/utilsor~/lib/utils. - Writes files, installs
dependencies, and merges anycssVarsinto the stylesheet.
Why imports are rewritten
The registry cannot know how your project is laid out. By authoring against a stable fake path and rewriting on install, one source file works in every project.
Registry versus package
| npm package | Registry | |
|---|---|---|
| You get | Compiled code in node_modules | Source files in your repo |
| Customizing | Props and theme API | Edit the file |
| Updating | Bump a version | Re-run add, review the diff |
| Publishing | Versioned release | Upload static JSON |