DEV Community

Alex Spinov
Alex Spinov

Posted on

shadcn/ui Has Free Copy-Paste Components — Not a Library, a Collection You Own

Most UI libraries lock you in. Update the library, and your custom styles break. shadcn/ui copies components directly into your project. You own every line.

What is shadcn/ui?

shadcn/ui is not an npm package. It's a collection of beautifully designed, accessible components built with Radix UI primitives and Tailwind CSS. You copy them into your project and modify them freely.

Why shadcn/ui Won

1. You Own the Code

# Add a button component
npx shadcn@latest add button

# This copies the component to your project:
# components/ui/button.tsx
Enter fullscreen mode Exit fullscreen mode
// You can modify ANYTHING — it's your file now
import { cn } from "@/lib/utils";

const Button = ({ className, variant, size, ...props }) => {
  return (
    <button
      className={cn(buttonVariants({ variant, size, className }))}
      {...props}
    />
  );
};
Enter fullscreen mode Exit fullscreen mode

No !important overrides. No styled() wrappers. Just edit the file.

2. Accessible by Default

Every component is built on Radix UI primitives:

  • Keyboard navigation
  • Screen reader support
  • Focus management
  • ARIA attributes
import {
  Dialog,
  DialogContent,
  DialogDescription,
  DialogHeader,
  DialogTitle,
  DialogTrigger,
} from "@/components/ui/dialog";

<Dialog>
  <DialogTrigger asChild>
    <Button variant="outline">Open</Button>
  </DialogTrigger>
  <DialogContent>
    <DialogHeader>
      <DialogTitle>Are you sure?</DialogTitle>
      <DialogDescription>This action cannot be undone.</DialogDescription>
    </DialogHeader>
  </DialogContent>
</Dialog>
Enter fullscreen mode Exit fullscreen mode

3. Theming with CSS Variables

/* globals.css */
:root {
  --background: 0 0% 100%;
  --foreground: 222.2 84% 4.9%;
  --primary: 222.2 47.4% 11.2%;
  --primary-foreground: 210 40% 98%;
}

.dark {
  --background: 222.2 84% 4.9%;
  --foreground: 210 40% 98%;
  --primary: 210 40% 98%;
}
Enter fullscreen mode Exit fullscreen mode

Change your entire theme by updating CSS variables. Dark mode included.

4. 50+ Components

Data display: Table, Card, Badge, Avatar, Calendar
Forms: Input, Select, Checkbox, Radio, Slider, DatePicker, Combobox
Feedback: Alert, Toast, Progress, Skeleton
Navigation: Tabs, Breadcrumb, Menubar, NavigationMenu, Sidebar
Overlay: Dialog, Sheet, Popover, Tooltip, Dropdown, Command, Drawer

5. CLI with Project Detection

# Initialize
npx shadcn@latest init

# Add specific components
npx shadcn@latest add dialog table form toast

# Add all components
npx shadcn@latest add --all
Enter fullscreen mode Exit fullscreen mode

The CLI detects your project setup (Next.js, Vite, Remix) and configures paths automatically.

6. Works Beyond React

shadcn/ui has ports for:

  • Vue (shadcn-vue)
  • Svelte (shadcn-svelte)
  • Solid (solid-ui)
  • Angular (spartan-ng)

shadcn/ui vs Material UI vs Chakra UI

shadcn/ui Material UI Chakra UI
Ownership Copy into project npm dependency npm dependency
Styling Tailwind CSS Emotion/styled Emotion/styled
Bundle impact Only what you use Tree-shakeable Tree-shakeable
Customization Edit source directly Theme overrides Theme overrides
Lock-in Zero Library updates Library updates
Accessibility Radix primitives Built-in Built-in

Getting Started

npx shadcn@latest init
npx shadcn@latest add button card dialog
Enter fullscreen mode Exit fullscreen mode

The Bottom Line

shadcn/ui solved the UI library dilemma. Beautiful defaults, accessible components, and zero lock-in. Copy, paste, own.


Need data tools? I build web scraping solutions. Check my Apify actors or email spinov001@gmail.com.

Top comments (0)