Install shadcn/ui with the CLI, then add only the components you need. That is the whole trick. Shadcn/ui is not a normal package of ready-made widgets. Its own docs describe it as code you copy into your app, so you can edit every part later [source: shadcn/ui].
TLDR: Start with a React app, run npx shadcn@latest init, then add items like npx shadcn@latest add button. For example, a small SaaS dashboard can add a button, card, dialog, and table in under 10 minutes. Teams often save dozens of tiny styling decisions because the defaults already look clean. The best part is simple: you own the code.
What is shadcn/ui?
shadcn/ui is a set of good-looking React components. Think buttons, cards, forms, menus, dialogs, tables, and toasts.
But here is the fun twist. You do not install one huge UI library and pray it behaves. You copy the component code into your project. Then it lives in your files.
That means you can change it. Break it. Fix it. Paint it purple. Nobody can stop you.
Honestly, it feels like buying furniture where the store also gives you the tools and the blueprint.
Before you start
You need a few things first.
- Node.js installed.
- A React project.
- Tailwind CSS set up.
- A package manager like npm, pnpm, yarn, or bun.
- A little patience. Just a little.
It works great with Next.js. It also works with Vite. If you are new, Next.js is usually the smoothest path.
Basic installation
For a fresh Next.js project, run this:
npx create-next-app@latest my-app
cd my-app
Pick TypeScript if asked. Pick Tailwind if asked. This keeps things easy.
Now run the shadcn setup command:
npx shadcn@latest init
The CLI will ask a few questions. Do not panic. Most defaults are fine.
- Style: choose the default style you like.
- Base color: slate is a safe pick.
- CSS variables: say yes if you want easy theme control.
- Components path: usually
components. - Utils path: usually
lib/utils.
After this, you will see files like components.json and lib/utils.ts. These help shadcn know where to place things.
Adding your first component
Let us add a button. Because every app needs a button that looks less sad.
npx shadcn@latest add button
Now use it in a page:
import { Button } from "@/components/ui/button"
export default function Page() {
return <Button>Click me</Button>
}
That is it. You now have a button. It is local code. You can open the file and edit it.
Want more? Add a card:
npx shadcn@latest add card
Or a dialog:
npx shadcn@latest add dialog
Image not found in postmeta
Useful components to install first
If you are building a normal app, start with these:
- Button: for actions.
- Card: for clean content blocks.
- Input: for forms.
- Label: for form text.
- Dialog: for popups.
- Dropdown Menu: for account menus.
- Table: for admin screens.
- Toast or Sonner: for small alerts.
A simple login page may only need Button, Input, Label, and Card. A dashboard may need ten or more. Add them as needed. Do not install everything just because you can.
Common issue: command not found
If this fails:
npx shadcn@latest init
Check Node first:
node -v
If Node is very old, update it. Old Node versions love causing strange errors. It drives me crazy that one outdated Node install can steal 20 minutes from a simple setup.
Also try clearing your package runner cache or using another package manager:
pnpm dlx shadcn@latest init
Common issue: import alias is broken
You may see errors like this:
Cannot find module "@/components/ui/button"
This means your path alias is not set right.
For TypeScript, check tsconfig.json. You want something like:
"paths": {
"@/*": ["./*"]
}
If your source code lives inside src, the path may need to point there instead.
Common issue: styles look wrong
If your button looks plain, Tailwind may not be reading the right files.
Check your Tailwind content paths. They should include your app and component files.
content: [
"./app//*.{ts,tsx}",
"./components//*.{ts,tsx}"
]
Also make sure your global CSS imports Tailwind layers.
@tailwind base;
@tailwind components;
@tailwind utilities;
Image not found in postmeta
Common issue: hydration errors
Some components use browser-only features. If you use Next.js, you may need a client component.
Add this at the top of the file:
"use client"
This often fixes dialogs, dropdowns, menus, and form controls.
Best practices
- Add components one by one. Keep your project clean.
- Commit after setup. Then you can undo mistakes fast.
- Read the component file. It is your code now.
- Keep naming simple. Future you will be grateful.
- Do not fight the defaults too early. Build first. Polish later.
Shadcn/ui is popular because it feels practical. You get clean UI fast. You keep control. And when something breaks, the code is right there in your project, not hidden in a locked box.
Best starting combo: Next.js, Tailwind CSS, TypeScript, and shadcn/ui. Add button, card, input, and dialog. Then build something real. That is the fastest way to learn it.