Component libraries are the backbone of modern web development. They speed up development, ensure consistency and provide a foundation for scalable applications. But there is a problem: most popular component libraries lock you into their design system. Want to customise that button? Good luck. Found an accessibility bug? Wait for the next release. This is where shadcn/ui is different. It is not just another component library; it is a copy-and-paste component system in which you own the code.
- Components
- React
- UI Library
- Web Development
In this article13 sections
- 01The problem with traditional component libraries
- 02Introducing shadcn/ui: a different approach
- 03How shadcn/ui works
- 04Key differences from other libraries
- 05Exploring three essential components
- 061. The button component
- 072. The card component
- 083. The form component (advanced)
- 09What has changed recently
- 10Pros and cons of shadcn/ui
- 11When to use shadcn/ui
- 12FAQs about shadcn/ui
- 13The bottom line
The problem with traditional component libraries#
I remember working as a consultant at SJ, a major Scandinavian transport company. We were using Material UI (MUI), one of the most popular React component libraries at the time. It was a solid choice, with comprehensive components, good documentation and an attractive design. Then we hit a wall.
Our design called for a custom drop-down select component with very specific accessibility features. MUI’s implementation had an accessibility problem that did not meet our requirements, and we were stuck. We filed issues, took part in discussions and waited for updates. Days turned into weeks. We were not alone: there were pages and pages of GitHub discussions from other developers facing similar problems.
The core issue? We had no control over the component source code. We were at the mercy of the library maintainers. Every change required a new release, every customisation required a workaround and every bug fix took time we did not have.
The experience exposed a fundamental flaw in the way component libraries are usually distributed: you are locked into their architecture, their decisions and their timeline.
Introducing shadcn/ui: a different approach#
shadcn/ui takes a fundamentally different approach. Instead of importing a component from an npm package, you copy the component code directly into your project. You own the code – every single line of it.
This may sound unconventional, but it works remarkably well. With a CLI tool and a component registry, shadcn makes it easy to add components to your project while you keep complete control of the source. When you run `npx shadcn@latest add button`, you are not installing a dependency – you are copying the component’s implementation into your codebase.
This means you can:
- Customise any component to match your exact needs, without workarounds
- Fix bugs immediately, without waiting for a release
- Understand how a component works by reading the actual code
- Change a component’s behaviour to fit your specific use case
shadcn builds on Radix UI primitives – unstyled, accessible components – and adds Tailwind CSS styling on top. The combination gives you complete flexibility without sacrificing accessibility.
How shadcn/ui works#
The shadcn/ui architecture is simple and well thought out:
1. Radix UI primitives: The foundation. These unstyled, accessible component primitives handle all the complex logic, such as keyboard navigation, focus management and ARIA attributes.
2. Tailwind CSS styling: shadcn adds clean, customisable styling on top using Tailwind utility classes.
3. Copy-and-paste installation: When you need a component, you do not install it from npm; you copy the code into your project.
4. Full ownership: Once the code is in your project, it is yours to customise, extend or modify.
This approach gives you the best of both worlds: the accessibility and careful architecture of Radix UI, plus the flexibility of controlling your own code.
Key differences from other libraries#
- Full control of the source code: Unlike Material UI or Bootstrap, you own every line of code. No more hidden implementations.
- Installation by copy and paste: Instead of running npm install, you get the source code directly. Updates are optional and happen on your schedule.
- Accessibility first: Built on Radix UI primitives, which follow WAI-ARIA patterns for keyboard and screen reader support. You still need to test how you use them.
- Headless foundation: Start with unstyled, accessible primitives and style them with Tailwind, with full scope for customisation.
- Modern stack: Uses React 19+, TypeScript, Vite and Tailwind CSS – the modern web development stack.
- Active community: A large and growing community creating examples, extensions and plugins.
Exploring three essential components#
1. The button component#
Let’s start with the most basic building block: the button. This is what shadcn’s button component looks like:
Live component
import * as React from "react"
import { Slot } from "@radix-ui/react-slot"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "@/lib/utils"
const buttonVariants = cva(
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md",
{
variants: { },
defaultVariants: {}
}
)
export interface ButtonProps extends React.ButtonHTMLAttributes {}
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : "button"
return (...)
}
)
Button.displayName = "Button"
export { Button, buttonVariants }Notice how clean this is: it uses `class-variance-authority` (CVA) to manage variants, Tailwind classes for styling and Radix’s Slot component for composition. You can create variants (default, destructive, outline, ghost, link) and sizes (default, sm, lg, icon) while keeping the code clean and maintainable.
Best of all, if you want to add a custom variant or change how the button looks, you simply edit this file. No waiting for a release and no filing an issue – you just change the code.
2. The card component#
Cards are a fundamental part of modern UI design. Here is shadcn’s implementation:
Live component
import * as React from "react"
import { cn } from "@/lib/utils"
const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes>(
({ className, ...props }, ref) => (
<div className={cn("rounded-lg border bg-card shadow-sm")} {...props} />
)
)
Card.displayName = "Card"
const CardHeader = React.forwardRef<HTMLDivElement, React.HTMLAttributes>(
({ className, ...props }, ref) => (
<div className={cn("flex flex-col space-y-1.5 p-6")} {...props} />
)
)
CardHeader.displayName = "CardHeader"
const CardTitle = React.forwardRef<HTMLHeadingElement, React.HTMLAttributes>(
({ className, ...props }, ref) => (
<h2 className={cn("text-2xl font-semibold")} {...props} />
)
)
CardTitle.displayName = "CardTitle"
const CardContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes>(
({ className, ...props }, ref) => (
<div className={cn("p-6 pt-0")} {...props} />
)
)
CardContent.displayName = "CardContent"
export { Card, CardHeader, CardTitle, CardContent }The card component shows the value of composability: it is built from smaller sub-components (CardHeader, CardTitle, CardContent and so on) that work together. This lets you build complex layouts from simple, reusable pieces. Want to change how cards look? Edit the Tailwind classes directly.
3. The form component (advanced)#
For a more complex example, shadcn provides a form component built with react-hook-form and Zod for validation:
Live component
import { useForm } from "react-hook-form"
import { zodResolver } from "@hookform/resolvers/zod"
import * as z from "zod"
const formSchema = z.object({
email: z.string().email(),
message: z.string().min(10),
})
export function ContactForm() {
const form = useForm<z.infer<typeof formSchema>>({{
resolver: zodResolver(formSchema),
})
function onSubmit(values) {
console.log(values)
}
return (
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)}>
<FormField {...} />
<Button type="submit">Send</Button>
form>
Form>
)
}This shows how shadcn fits in with modern React patterns. The form component uses react-hook-form for state management and Zod for type-safe validation. Everything can be customised, because you own the code.
What has changed recently#
The project moves quickly. These are the changes that matter most for teams adopting it today:
- A new CLI
The CLI is now called <code>shadcn</code> (<code>npx shadcn@latest</code>). It detects your framework, sets up the project and can install components from any registry URL, including your own.
- React 19 and Tailwind CSS v4
Components have been updated for React 19 and Tailwind v4. <code>forwardRef</code> is gone, and colours are defined in OKLCH.
- Theming with CSS variables
Themes are plain CSS variables, so dark mode and brand themes are a matter of swapping tokens.
- More building blocks
Charts, a sidebar and ready-made blocks such as dashboards and login screens, all copied into your codebase like any other component.
Because the code lives in your repository, upgrades are never forced on you. Check the changelog before pulling in new versions of components you have already customised.
Pros and cons of shadcn/ui#
Advantages
- Complete control of the source code: Customise any component without limitations
- Accessibility-first architecture: Built on Radix UI, with WAI-ARIA compliance
- Modern tech stack: React, TypeScript, Tailwind CSS, Vite
- Copy-and-paste simplicity: Easy to add components without dependency management issues
- Active community: A large ecosystem of examples and extensions
- No version lock-in: Update components on your own schedule
Considerations
- Manual updates required: You are responsible for updating the component code
- Some learning curve: Requires an understanding of Radix UI and Tailwind CSS
- Possible code duplication: Without care, you may end up duplicating component code across projects
- Less “batteries included”: You assemble components yourself rather than importing a complete design system
When to use shadcn/ui#
shadcn/ui is a good fit when:
- You need complete control over how components are implemented
- You want to avoid vendor lock-in with traditional component libraries
- You are building a custom design system for your brand
- You need accessibility-first components with a solid, ARIA-based foundation
- Your team is comfortable with modern React patterns (hooks, TypeScript and so on)
- You value understanding the underlying code over a quick setup
It is less suitable if you need a complete, ready-made design system out of the box, or if your team prefers traditional npm dependencies.
FAQs about shadcn/ui#
How is shadcn different from Material UI or Bootstrap?
Unlike Material UI and Bootstrap, shadcn/ui gives you the actual component source code, which you copy into your project. You own the code completely, can customise it without limits and do not depend on the library maintainers for updates.
Is shadcn a component library or a copy-and-paste service?
It is both. shadcn provides a registry of components and a CLI tool that copies the source code into your project. It is component code you own, not a traditional npm dependency.
Do I need to understand Radix UI to use shadcn?
You do not need in-depth knowledge of Radix, but understanding its primitives helps. The good news is that shadcn handles most of the complexity for you; you mainly work with the styled components.
Can I use shadcn with TypeScript?
Yes. shadcn is built with TypeScript and provides full type support. All components are typed, and your IDE will give you excellent autocomplete.
Is shadcn suitable for production applications?
Yes, many production applications use shadcn. Because you control the code, you can make sure it meets your production requirements. Regular updates to the component registry keep it compatible with new React releases.
How do I update components when shadcn releases improvements?
You can pull the latest version from the registry manually and merge it into your code, or use the CLI to regenerate components. It is your choice; you are never forced to update.
Does shadcn include all the components I might need?
shadcn has a solid collection of essential UI components. For more specialised components, you can use extensions created by the community, or build your own using the same patterns.
Can I use shadcn with CSS-in-JS libraries instead of Tailwind?
shadcn is built around Tailwind CSS, but because you own the code, you can adapt it to any CSS solution. That said, Tailwind is the default.
Is there a performance difference between shadcn and other libraries?
Because you copy the code into your project, performance is essentially the same as for your own custom components. You have full control to optimise as needed.
Can I create a monorepo with shared shadcn components?
Yes. Many teams use shadcn as the foundation for custom design systems in monorepos. You can build your own component library on top of shadcn’s patterns.
The bottom line#
shadcn/ui represents a fundamental change in how we think about component libraries. Instead of being locked into a third party’s decisions, you get well-designed, accessible, modern components that are entirely yours to control.
The lesson from my time at SJ, struggling with that MUI drop-down accessibility issue, is that control of the source code matters. When you own the code, you own your future. shadcn makes that possible without sacrificing quality, accessibility or modern design patterns.
Whether you are building a new product, creating a custom design system or simply tired of fighting the limitations of component libraries, shadcn/ui deserves serious consideration. It is not just another component library. It is a philosophy: your code, your components, your control.
Sources
What this article is built on
- [1]shadcn/ui official documentation ui.shadcn.com
- [2]shadcn/ui changelog ui.shadcn.com
- [3]shadcn component examples and showcase shadcnstudio.com
- [4]Radix UI – unstyled component primitives radix-ui.com
- [5]Tailwind CSS – utility-first CSS framework tailwindcss.com