DEV Community

Alex Spinov
Alex Spinov

Posted on

shadcn/ui Has Free Copy-Paste Components That You Own — Not a Package, Not a Dependency

The Component Library Problem

MUI: 200KB+ bundle. Chakra UI: locked into their API. Both: when they change, your app breaks. Version upgrades are migration projects.

shadcn/ui copies components into YOUR codebase. You own the code. No dependency. No breaking updates.

What shadcn/ui Gives You

CLI-Driven Component Install

npx shadcn@latest init
npx shadcn@latest add button
npx shadcn@latest add dialog
npx shadcn@latest add data-table
Enter fullscreen mode Exit fullscreen mode

Each command creates a .tsx file in YOUR project. You can read, edit, and customize every line.

Beautifully Designed Components

import { Button } from '@/components/ui/button';
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from '@/components/ui/dialog';

export function Example() {
  return (
    <Dialog>
      <DialogTrigger asChild>
        <Button variant="outline">Open Dialog</Button>
      </DialogTrigger>
      <DialogContent>
        <DialogHeader>
          <DialogTitle>Edit Profile</DialogTitle>
        </DialogHeader>
        <p>Your form here</p>
      </DialogContent>
    </Dialog>
  );
}
Enter fullscreen mode Exit fullscreen mode

Theming With CSS Variables

:root {
  --primary: 222.2 47.4% 11.2%;
  --primary-foreground: 210 40% 98%;
  --radius: 0.5rem;
}

.dark {
  --primary: 210 40% 98%;
  --primary-foreground: 222.2 47.4% 11.2%;
}
Enter fullscreen mode Exit fullscreen mode

Change colors by editing CSS variables. Dark mode built in.

50+ Components

Button, Card, Dialog, Dropdown, Form, Input, Select, Table, Tabs, Toast, Tooltip, Sheet, Drawer, Command, Calendar, Chart, Carousel, and more.

Built on Radix UI + Tailwind CSS

Accessible by default (ARIA, keyboard navigation). Styled with Tailwind utility classes. Headless primitives from Radix UI.

Why NOT a Package?

With npm packages:

  • Breaking changes in v2 → your app breaks
  • Can't customize internal behavior
  • Bundle includes unused components

With shadcn/ui:

  • Code is yours → customize anything
  • No version updates to manage
  • Tree-shaking is automatic (it's your code)

Quick Start

npx create-next-app@latest my-app
cd my-app
npx shadcn@latest init
npx shadcn@latest add button card input
Enter fullscreen mode Exit fullscreen mode

Why This Matters

Component libraries shouldn't be black boxes you can't customize. shadcn/ui proved that the best DX is giving developers the source code.


Building data dashboards with shadcn/ui? Check out my web scraping actors on Apify Store — structured data for your tables and charts. For custom solutions, email spinov001@gmail.com.

Top comments (0)