If you have built a React app in the last two years, you have almost certainly used shadcn/ui — or copied a component from a project that did. And yet most setup guides still describe the shadcn/ui of 2024: install Radix, pick the New York style, done. A shadcn/ui setup in late 2026 looks different. The default primitive library changed in July, the CLI grew presets, registries, and a migration command, and Tailwind v4 rewired the theming. This guide walks through the whole setup, current as of 23 November 2026, on Next.js 16 with Tailwind CSS v4.
What shadcn/ui actually is (and is not)
shadcn/ui is not a component library. You cannot npm install it and import a Button from node_modules. It is a distribution system: you run a CLI, it copies component source code into your repository, and from that moment the code is yours to edit like any other file. There is no version to upgrade, no wrapper API to fight, and no lock-in — if you stop liking a component, you rewrite it in place.
Each component is three well-chosen pieces glued together. An unstyled headless primitive handles the genuinely hard parts — focus management, keyboard interaction, portalling, ARIA wiring. Tailwind supplies the styling. Class Variance Authority supplies the variant API, so <Button variant="outline"> reads the way you expect. A shared cn() helper merges the class names.
What you need before you run init
The init command runs four preflight checks in order and stops at the first one that fails: an existing components.json, a supported framework, Tailwind CSS, and import aliases. So before you touch the CLI, make sure two things are true.
First, Tailwind must already be installed and working. On a fresh Next.js 16 project, create-next-app installs Tailwind v4 for you when you accept the recommended defaults. On an existing project, install Tailwind first — shadcn/ui does not install or configure it for you. Both Tailwind v3 and v4 are supported; v3 needs a config file and a CSS file, v4 needs only the CSS file.
Second, your tsconfig.json must already define the @/* import alias — init reads it and never writes it. The standard mapping is:
{
"compilerOptions": {
"paths": {
"@/*": ["./*"]
}
}
}
If you used --src-dir, point the alias at ./src/* instead.
Step 1: Scaffold the Next.js app
If you need a new project, create one with create-next-app and choose the recommended defaults so Tailwind CSS, the App Router, and the default @/* import alias are configured for you:
pnpm create next-app@latest my-app
cd my-app
If you prefer a src/ directory, pass --src-dir. If you already have a project, skip this step entirely.
Step 2: Run init — and answer the prompts like you mean it
Run the init command in your project root:
pnpm dlx shadcn@latest init
The CLI installs the dependencies it needs, writes components.json, adds the theme variables to your stylesheet, and creates src/lib/utils.ts with the cn() helper. Three answers deserve deliberate thought rather than four presses of Enter.
Which base: Base UI, Radix, or React Aria
This is the question most tutorials get wrong, because the answer changed on 3 July 2026: new shadcn/ui projects now default to Base UI instead of Radix. Base UI is built by the people behind Radix, Material UI, and Floating UI, and it had reached a stable 1.6.0 with over six million weekly downloads when the switch landed — 1.8.0 followed on 4 September 2026. It covers primitives Radix never shipped, such as Combobox, Autocomplete, Number Field, Toast, and Preview Card. Radix is not deprecated: the team still runs it in its own production apps, every update ships for both libraries, and -b radix keeps Radix on a fresh project. If your CI or scaffolding scripts call init non-interactively and expect Radix, add that flag now, before a fresh checkout surprises you.
Which preset: nova, vega, maia, and friends
Presets bundle a visual style — colours, fonts, icons, and radius — into a single choice. Nova is the default and pairs Lucide icons with Geist; the others are vega, maia, lyra, mira, luma, sera, and rhea. The choice is saved in the style field of components.json, so Base UI with Nova is recorded as base-nova. You can also build a preset visually at shadcn/create and paste the generated command:
pnpm dlx shadcn@latest init --preset [CODE] --template next
Want zero prompts? init -d takes the defaults (--template=next --preset=nova). And if you want the CLI to scaffold a brand-new project instead of wiring up an existing one, pass a template: pnpm dlx shadcn@latest init -t next. Templates exist for Next.js, Vite, TanStack Start, React Router, Laravel, and Astro.
CSS variables, monorepo, RTL
Say yes to CSS variables — they are how theming works, and they default to on. If you are in a monorepo, --monorepo scaffolds the shared-package layout, and later add commands take a -c apps/web flag or run from inside the app. RTL support is a flag too (--rtl), which is easier to enable at init than to retrofit.
Step 3: Add your first components
Adding a component copies its source into components/ui/ and installs whatever that component depends on. Pass several at once — the CLI resolves shared dependencies rather than installing them repeatedly:
pnpm dlx shadcn@latest add button card dialog form input
Then import from the alias, exactly as the official docs show:
import { Button } from "@/components/ui/button"
export default function Home() {
return (
<div className="flex min-h-svh items-center justify-center">
<Button>Click me</Button>
</div>
)
}
Four flags earn their keep. --dry-run prints what would be written without writing it. --view shows the component source in the terminal so you can read it before it lands in your tree. --diff shows what has changed upstream relative to the copy you already have — how you pick up an accessibility fix without overwriting your own edits. --overwrite replaces the local file outright. --all installs every component: useful for a design-system sandbox, a mistake in a real app.
Step 4: Understand what just landed in your repo
Three files do the work. Knowing what each one is for saves you from “fixing” things that are not broken.
components.json is the CLI’s memory. It records the style, the Tailwind base colour, whether CSS variables are on, and the import aliases — so an aliases.ui of @/components/ui writes to src/components/ui when @/* maps to ./src/*. Three of its fields cannot be changed afterwards without regenerating everything, so decide them deliberately at init. On Tailwind v4, leave tailwind.config as an empty string — there is no JavaScript config file for it to point at, and a stale path produces a confusing error on the next add.
lib/utils.ts holds the cn() helper every component uses: clsx handles conditionals and arrays, then tailwind-merge deduplicates conflicting Tailwind classes, so px-2 beats px-4 when both appear. Passing your className through cn() is how you override a component’s defaults without specificity fights. One 2026 footnote: the CLI now ships a migrate cn command that swaps this classic util for the standalone cn package — a single re-export. You do not need it on a fresh project, but it is the tidy-up for an old codebase that still carries both packages.
app/globals.css holds the theme. Tailwind v4 is configured inside this CSS file — there is no tailwind.config.js anymore. The CLI appends an @theme inline block that maps Tailwind colour tokens to CSS variables, plus :root and .dark blocks holding the actual values in OKLCH, which gives more perceptually uniform colours than the old HSL tokens:
@import "tailwindcss";
@custom-variant dark (&:is(.dark *));
@theme inline {
--color-background: var(--background);
--color-foreground: var(--foreground);
--color-primary: var(--primary);
/* ... */
}
:root {
--background: oklch(1 0 0);
--foreground: oklch(0.145 0 0);
/* ... */
}
.dark {
--background: oklch(0.145 0 0);
/* ... */
}
Theming is CSS variables, not a configuration object. To change your brand colour, you edit a variable — you never touch a component.
Step 5: Dark mode in five minutes
Dark mode is next-themes plus one wrapper. Install the package, add a small client component, and wrap your root layout:
pnpm add next-themes
// components/theme-provider.tsx
"use client"
import * as React from "react"
import { ThemeProvider as NextThemesProvider } from "next-themes"
export function ThemeProvider({
children,
...props
}: React.ComponentProps<typeof NextThemesProvider>) {
return <NextThemesProvider {...props}>{children}</NextThemesProvider>
}
// app/layout.tsx
import { ThemeProvider } from "@/components/theme-provider"
export default function RootLayout({ children }: RootLayoutProps) {
return (
<html lang="en" suppressHydrationWarning>
<body>
<ThemeProvider
attribute="class"
defaultTheme="system"
enableSystem
disableTransitionOnChange
>
{children}
</ThemeProvider>
</body>
</html>
)
}
Two details matter. The suppressHydrationWarning on <html> is required because next-themes adds the theme class on the client, which would otherwise surface as a hydration mismatch. And attribute="class" is what makes the .dark block in your CSS actually apply: the provider toggles a class, and the @custom-variant dark line in globals.css keys off it. Add a mode toggle with useTheme() from next-themes and you are done.
Build something real: a dashboard card and a validated form
Here are the two patterns you will actually reach for first. A stat card is the fastest way to see the Card component earn its keep:
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card"
export function SignupsCard() {
return (
<Card className="max-w-sm">
<CardHeader>
<CardTitle>Signups this week</CardTitle>
<CardDescription>New accounts, last 7 days.</CardDescription>
</CardHeader>
<CardContent>
<p className="text-4xl font-bold">1,284</p>
<p className="text-sm text-muted-foreground">Up 18% on last week</p>
</CardContent>
</Card>
)
}
The Form component wraps React Hook Form with accessible labels and error messages, and pairs naturally with Zod validation:
"use client"
import { zodResolver } from "@hookform/resolvers/zod"
import { useForm } from "react-hook-form"
import { z } from "zod"
import { Button } from "@/components/ui/button"
import {
Form,
FormControl,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form"
import { Input } from "@/components/ui/input"
const formSchema = z.object({
username: z.string().min(2, {
message: "Username must be at least 2 characters.",
}),
})
export function ProfileForm() {
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
defaultValues: { username: "" },
})
function onSubmit(values: z.infer<typeof formSchema>) {
console.log(values)
}
return (
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-8">
<FormField
control={form.control}
name="username"
render={({ field }) => (
<FormItem>
<FormLabel>Username</FormLabel>
<FormControl>
<Input placeholder="shadcn" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<Button type="submit">Submit</Button>
</form>
</Form>
)
}
Notice the "use client" directive: Form, Dialog, and the other interactive components are client components, and they must live behind a client boundary in the App Router. The CLI sets rsc: true for App Router projects, which is its way of knowing that. Keep the boundary at the smallest component that needs it and let the rest of the page stay a Server Component.
Base UI vs Radix vs React Aria: which base should you pick?
Three bases, one decision. The honest default for a new project in late 2026 is Base UI — it is what init picks, it has the primitives Radix never shipped, and it is where new components land first. Stay on Radix if the app is stable, you are not blocked on a missing primitive, and nobody on the team has a specific complaint. React Aria is the choice when you need the deepest accessibility behaviour and are willing to pay for it in verbosity. The team has committed to shipping every update and every new component for both Base UI and Radix, the one exception being components that exist in Base UI and have no Radix counterpart — so this is a starting point, not a trapdoor.
If you do move an existing Radix project to Base UI, the changes split into two groups: the build-breaking ones, which are mechanical renames the compiler catches immediately, and the silent ones, which compile fine and change behaviour — and are worse:
| Radix | Base UI |
|---|---|
asChild on triggers |
render prop |
Portal > Content |
Portal > Positioner > Popup |
Overlay |
Backdrop |
data-[state=open]: |
data-open: |
onOpenChange(open) + event.preventDefault() |
onOpenChange(open, details) + details.cancel() |
Controlled Select holds string |
Controlled Select holds Value | null |
| Arrow keys move focus and activate tabs | Arrow keys move focus; Enter or Space activates |
The asChild to render change is the one everyone meets first:
// Radix
<DialogTrigger asChild>
<Button>Open</Button>
</DialogTrigger>
// Base UI
<DialogTrigger render={<Button />}>Open</DialogTrigger>
The render prop takes an element or a function, and the function form gives you the component’s state — handy for a trigger that changes its icon when open. Migrate one component per commit, keep both libraries installed while you do it, and use the official shadcn skill rather than a codemod: the silent behaviour changes are exactly the kind a codemod cannot see.
Beyond components: presets, registries, and blocks
The registry is the part of shadcn/ui that most setup guides skip, and it is where the 2026 CLI earns its keep. The registry has expanded well beyond UI primitives: you can now install charts (built on Recharts), sidebar navigation, dashboard blocks, and full authentication forms as single CLI commands. Third-party registries work the same way, and your team can publish one with shadcn build.
Presets travel as short codes. Build one visually at shadcn/create, share the code, and anyone can apply it — or just its theme or fonts — to an existing project:
pnpm dlx shadcn@latest apply a2r6bw --only theme
pnpm dlx shadcn@latest preset decode a2r6bw
pnpm dlx shadcn@latest preset resolve
Two more commands round out the toolbox: shadcn docs button fetches a component’s documentation and API reference without opening a browser, and shadcn migrate lists migrations for moving a project to a new base, icon library, or colour.
7 mistakes that waste your first afternoon
1. Running init before Tailwind works. The CLI checks your framework, Tailwind, and aliases before it does anything, and stops at the first failure. Install Tailwind first, confirm the @/* alias exists, then run init.
2. Treating it as an npm package. There is no npm install shadcn-ui that gives you components. If a tutorial tells you to install it, the tutorial is wrong — or describing something else entirely.
3. Pressing Enter through the prompts. The base and preset you pick are saved in components.json, and three of its fields cannot change without regenerating everything. Decide Base UI vs Radix and your preset deliberately; defaults are fine, but they should be chosen defaults.
4. Leaving a stale tailwind.config path on v4. Tailwind v4 has no JavaScript config file. Leave tailwind.config as an empty string in components.json, or the next add fails with a confusing error.
5. Editing a component, then re-adding it blind. Your edits are the point of owning the code — but add without --diff overwrites them. Check the diff first, every time you re-add a component you have customised.
6. Putting interactive components in Server Components. Dialog, Form, and friends need a client boundary. Keep "use client" on the smallest component that needs it and let the rest of the page stay server-rendered.
7. Copying Radix-era code into a Base UI project. asChild, data-[state=open]:, and Portal > Content are Radix idioms. In a Base UI project they are render, data-open:, and Portal > Positioner > Popup. Any tutorial dated before July 2026 teaches the old ones — check the date before you copy.
Done this way, setup takes about fifteen minutes and leaves you with something no component library gives you: a design system that is just your code, in your repo, editable without asking anyone’s permission.
Verified 23 November 2026 against the official shadcn/ui docs (installation, CLI, dark mode), the Base UI switch coverage, and the current CLI reference.
Further Reading & References
- Next.js — shadcn/ui installation docs — the official setup: create, init, add, monorepo, and the
@/*alias requirement. - shadcn CLI — official reference — every command and flag: init, add, apply, preset, view, search, build, docs, info, migrate.
- Dark Mode (Next.js) — shadcn/ui docs — the official next-themes setup, ThemeProvider, and root-layout wiring.
- How to Add shadcn/ui to Next.js (2026 Guide) — inbuild.io — the clearest independent walkthrough of init, theming, and the registry, updated September 2026.
- shadcn/ui switched to Base UI. Here is what actually changes in your code — DEV — every API difference from the 3 July 2026 switch, build-breaking and silent.
- shadcn/ui Has Switched From Radix to Base UI — OpenReplay Blog — why the default moved, what stays supported, and the migration order.
- shadcn/ui + Next.js 16: 2026 Setup Guide — Next.js Launchpad — the 2026 CLI, Tailwind v4 theming, and the expanded registry (charts, blocks, auth forms).
- Next.js + Tailwind v4 + shadcn/ui — React SME Cookbook — a copy-paste recipe card for the exact stack in this guide, including the
cn()helper and components.json shape. - Tailwind CSS v4: The Complete Guide for 2026 — HowToShipIt — the v4 fundamentals this guide builds on: CSS-first config, @theme tokens, and dark mode.
- Upgrade Next.js 15 to 16: The EOL Checklist — HowToShipIt — the 15→16 upgrade path if your app is still on the old major.
- How to Fix React Hydration Errors in Next.js — HowToShipIt — why
suppressHydrationWarningexists and the seven causes of hydration mismatches.



