Skip to content
STACK IT FAST

shadcn/ui

Curated OSSHybridCopy-Paste UI Component Architecture1M+ MAU

Audited from github.com/shadcn-ui/ui

shadcn/ui is a collection of re-usable, accessible components built with Radix UI and Tailwind CSS that you can copy and paste into your apps.

Language
TypeScript
License
MIT
Running for
2 years 6 months
Team
1M+ MAU

Why this architecture

Distributing components as source code gives developers full ownership and customization freedom while pairing Radix accessibility with Tailwind utility styling.

Tech stack by layer

8 technologies · audited Sep 17, 2026
Frontend & UI
  • ReactFoundational UI framework for composable, accessible component primitives in packages/react.
  • Tailwind CSSUtility-first CSS styling using modern CSS variables and color tokens in apps/v4.
  • Radix UIAccessible, unstyled component primitives providing keyboard navigation and ARIA patterns.
Backend & APIs
  • TypeScriptStrictly typed component schemas, CLI AST transformers, and registry definitions.
  • Next.jsPowers the interactive documentation portal, live preview registry, and blocks showcase.
Infrastructure & Deploy
  • TurborepoBuild orchestration tool in turbo.json coordinating monorepo tasks and registry builds.
  • pnpmWorkspace package manager managing strict dependencies across packages, apps, and templates.
  • ViteFast bundler powering unit test harnesses and template project scaffolds.

shadcn/ui architecture diagram

Open SVG
shadcn/ui architecture diagramDeveloper → shadcn CLI (add component); AI coding assistant → MCP server (tools); shadcn CLI → Registry items (fetch items); MCP server → Registry items (discover); ui.shadcn.com → Registry items (publishes); Registry items → Component source (source files); shadcn CLI → User project (copy source)CLIENTSSERVICESWORKERS & JOBSDATA & STORAGEEXTERNALDevelopernpx shadcn addAI coding assistantMCP clientshadcn CLITypeScript · AST transformsMCP server@modelcontextprotocol/sdkui.shadcn.comNext.js · docs · blocksRegistry itemsJSON manifests over HTTPComponent sourceReact · Radix UI · TailwindUser projectNext.js · Vite · Astro · moreadd componenttoolsfetch itemsdiscoverpublishessource filescopy source
How the main components of shadcn/ui connect, drawn from the audited repository.
Diagram as text
  • Developer (npx shadcn add) → shadcn CLI (TypeScript · AST transforms): add component
  • AI coding assistant (MCP client) → MCP server (@modelcontextprotocol/sdk): tools
  • shadcn CLI (TypeScript · AST transforms) → Registry items (JSON manifests over HTTP): fetch items
  • MCP server (@modelcontextprotocol/sdk) → Registry items (JSON manifests over HTTP): discover
  • ui.shadcn.com (Next.js · docs · blocks) → Registry items (JSON manifests over HTTP): publishes
  • Registry items (JSON manifests over HTTP) → Component source (React · Radix UI · Tailwind): source files
  • shadcn CLI (TypeScript · AST transforms) → User project (Next.js · Vite · Astro · more): copy source

Key architectural decisions

5 decisions
  1. 01

    Component distribution as source code rather than npm package abstraction

    Rather than distributing components as a compiled node_modules dependency, the shadcn CLI copies raw, customizable React source files directly into the developer codebase.

  2. 02

    Decoupled headless logic from styling using Radix UI and Tailwind CSS

    Accessibility, focus trapping, and keyboard navigation are handled by headless primitives (Radix UI, Base UI), while visual styling is declared explicitly via Tailwind CSS classes.

  3. 03

    HTTP JSON registry protocol replaces proprietary package publishing

    Components are published as declarative JSON manifests (packages/shadcn/src/registry) over standard HTTP endpoints, enabling any CLI or tool to fetch and assemble components.

  4. 04

    Model Context Protocol (MCP) integration for AI agent workflows

    The CLI includes a dedicated MCP server (@modelcontextprotocol/sdk in packages/shadcn) that allows AI coding assistants to discover, inspect, and install UI components programmatically.

  5. 05

    Multi-framework starter templates maintained in monorepo

    The templates/ directory maintains verified starter applications for Next.js, Vite, Astro, React Router, and TanStack Start, ensuring cross-framework CLI compatibility.

How shadcn/ui is built

How shadcn/ui is structured

shadcn/ui is organized as a Turborepo monorepo managed with pnpm (pnpm-workspace.yaml, package.json). The repository manages the documentation website, the CLI distribution tool, component registry generators, and multi-framework templates:

  • packages/shadcn/: The core CLI tool published to npm as shadcn (packages/shadcn/package.json). It handles project initialization (shadcn init), component addition (shadcn add), registry publishing, AST code transformations (ts-morph, recast), and an embedded MCP server.
  • apps/v4/: The official documentation website and component showcase portal (apps/v4/package.json) built with Next.js, Fumadocs MDX, and Tailwind CSS v4.
  • packages/react/: Headless unstyled components and utility hooks (packages/react/package.json).
  • packages/helpers/: Integration helpers connecting components to AI SDKs (@ai-sdk/react, @tanstack/ai).
  • templates/: Full starter boilerplates demonstrating clean integrations with Next.js App Router, Vite, Astro, React Router v7, and TanStack Start.

Frontend

The presentation layer in apps/v4 and the individual components in the registry are built with React 19 (react, react-dom in apps/v4/package.json) and TypeScript.

The UI philosophy centers on composability and accessibility:

  • Headless Foundations: Interactive behaviors (dialogs, dropdown menus, popovers, tabs, accordions) rely on headless primitives from Radix UI (radix-ui) and Base UI (@base-ui/react). These primitives guarantee WAI-ARIA compliance, keyboard navigation, and focus management out of the box.
  • Styling Architecture: Visual presentation uses utility-first Tailwind CSS. Component variants and states are declared using Class Variance Authority (class-variance-authority), and conflicting utility classes are safely merged using clsx and tailwind-merge (via the standard cn() utility).
  • Icons & Polish: Standard components integrate Lucide icons (lucide-react) and Framer Motion / Motion (motion version 12) for smooth micro-animations.

Backend & APIs

While shadcn/ui is predominantly client-side code, it incorporates sophisticated tooling and registry infrastructure:

  1. shadcn CLI (packages/shadcn): A Node.js command-line interface that inspects target project configurations (components.json), resolves TypeScript path aliases, detects installed package managers (npm, pnpm, bun, yarn), and uses ts-morph to inject CSS variables and import statements into user projects.
  2. Component Registry API: Components are compiled into static JSON artifacts via registry:build (apps/v4/scripts/build-registry.mts). Each component manifest describes its file dependencies, registry dependencies, npm packages, and raw source code, served statically over HTTP CDN endpoints (e.g., https://ui.shadcn.com/r/button.json).
  3. Model Context Protocol (MCP): The CLI packages an MCP server implementation (packages/shadcn/src/mcp) that exposes registry search, component source inspection, and automated code generation tools to AI agents like Claude and Cursor.

Data & persistence

shadcn/ui has no database dependencies. State and configuration reside in:

  • components.json: The local configuration file stored in consumer project roots, tracking chosen style presets, CSS variables, path aliases, and Tailwind prefixes.
  • Component Manifests: Declarative JSON schemas validated via Zod (packages/shadcn/src/schema/index.ts) describing registry items, blocks, hooks, and themes.

Build, test & deploy

The monorepo build pipeline is managed with Turborepo (turbo.json):

  • Compilation: Packages build using tsup for rapid bundle generation, while the web application builds using Next.js Turbopack (next build).
  • Testing: Unit tests run across packages using Vitest (vitest.workspace.ts). End-to-end component validation and browser tests execute using Playwright and Puppeteer.
  • Continuous Integration: GitHub Actions workflows validate registries (validate-registries.yml), run template build checks (templates.yml), and automate releases with Changesets.

Self-hosting notes

Organizations can self-host private component registries:

  1. Export components into the standard shadcn registry schema using pnpm registry:build.
  2. Host the resulting JSON files on any static web server, S3 bucket, or internal artifact registry.
  3. Configure developer CLIs by pointing the registry URL to the private host: npx shadcn add https://internal.company.com/r/button.json.

What to copy (and what not to)

Key architectural innovations from shadcn/ui:

  • Code ownership over library abstraction: Providing source code directly into projects removes abstraction layers, giving developers total freedom to modify styles and accessibility rules without waiting for upstream package releases.
  • Headless logic paired with design tokens: Separating complex DOM interaction logic (Radix UI) from styling tokens (Tailwind CSS) produces clean, robust, and accessible UI components.
  • Open registry specifications: Distributing UI components as plain JSON manifests over standard HTTP creates an open ecosystem that any tool or AI assistant can query and assemble.

Avoid copying components manually into projects without a unified cn() merge utility or consistent design token system, as arbitrary ad-hoc styling causes visual drift and maintenance headaches over time.

Sources & repo audit

Audited
Sep 17, 2026
Commit
a87a63b
License
MIT

Independent analysis of repository at github.com/shadcn-ui/ui. Spotted an inaccuracy? Use the claim form to request a correction.

Show this stack on your README or website
Tech stack of shadcn/ui
[![Tech stack of shadcn/ui on STACK IT FAST](https://stackitfast.com/badge/shadcn-ui.svg)](https://stackitfast.com/project/shadcn-ui)

Paste it into your README. It shows your current stack and links to this page.

Use this stack

Scaffold it with your agent

Paste this prompt into Claude Code, Cursor, Windsurf or AGY to start a project with shadcn/ui's architecture.

  1. 1Copy the promptThe full markdown spec, with every layer and decision.
  2. 2Open your AI toolClaude Code, Cursor, Windsurf or Copilot, in a new repo.
  3. 3Paste and scaffoldUse it as the first instruction; review before you ship.
use-this-stack.md · 58 lines · 6.1 KB
# MISSION: Scaffold "shadcn/ui" Production Architecture
You are an expert Senior Staff Software Architect and Full-Stack Engineer. Your mission is to scaffold and implement a production-grade, highly reliable, and modular codebase following the proven architecture of **shadcn/ui**.
---
## 1. PROJECT SPECIFICATIONS & BENCHMARK
- **Reference Architecture**: shadcn/ui
- **What It Does**: shadcn/ui is a collection of re-usable, accessible components built with Radix UI and Tailwind CSS that you can copy and paste into your apps.
- **Domain & Category**: Copy-Paste UI Component Architecture
- **Production Scale**: 1M+ MAU
- **Development Mode**: HYBRID
- **Architectural Rationale**: Distributing components as source code gives developers full ownership and customization freedom while pairing Radix accessibility with Tailwind utility styling.
- **Live Website Reference**: https://ui.shadcn.com
- **Source Repository**: https://github.com/shadcn-ui/ui
---
## 2. PRODUCTION TECH STACK
- **Full Stack Array**: React, Tailwind CSS, Radix UI, TypeScript, Turborepo, pnpm, Next.js, Vite
- **Primary Language(s)**: TypeScript, MDX, CSS
- **License of the reference repo**: MIT
- **Frontend**: React — Foundational UI framework for composable, accessible component primitives in packages/react.; Tailwind CSS — Utility-first CSS styling using modern CSS variables and color tokens in apps/v4.; Radix UI — Accessible, unstyled component primitives providing keyboard navigation and ARIA patterns.
- **Backend & APIs**: TypeScript — Strictly typed component schemas, CLI AST transformers, and registry definitions.; Next.js — Powers the interactive documentation portal, live preview registry, and blocks showcase.
- **Infrastructure & deploy**: Turborepo — Build orchestration tool in turbo.json coordinating monorepo tasks and registry builds.; pnpm — Workspace package manager managing strict dependencies across packages, apps, and templates.; Vite — Fast bundler powering unit test harnesses and template project scaffolds.
---
## 3. KEY ARCHITECTURAL DECISIONS (audited from https://github.com/shadcn-ui/ui @ a87a63b)
1. **Component distribution as source code rather than npm package abstraction**: Rather than distributing components as a compiled node_modules dependency, the shadcn CLI copies raw, customizable React source files directly into the developer codebase.
2. **Decoupled headless logic from styling using Radix UI and Tailwind CSS**: Accessibility, focus trapping, and keyboard navigation are handled by headless primitives (Radix UI, Base UI), while visual styling is declared explicitly via Tailwind CSS classes.
3. **HTTP JSON registry protocol replaces proprietary package publishing**: Components are published as declarative JSON manifests (packages/shadcn/src/registry) over standard HTTP endpoints, enabling any CLI or tool to fetch and assemble components.
4. **Model Context Protocol (MCP) integration for AI agent workflows**: The CLI includes a dedicated MCP server (@modelcontextprotocol/sdk in packages/shadcn) that allows AI coding assistants to discover, inspect, and install UI components programmatically.
5. **Multi-framework starter templates maintained in monorepo**: The templates/ directory maintains verified starter applications for Next.js, Vite, Astro, React Router, and TanStack Start, ensuring cross-framework CLI compatibility.
---
## 4. NON-NEGOTIABLE ARCHITECTURAL GUARDRAILS
1. **Monorepo & Modular Separation**:
   - Structure as a Turborepo monorepo with strict package boundaries:
     - `apps/web`: Application UI, routing, layouts, and server endpoints.
     - `packages/ui`: Shared design tokens, CSS variables, and Radix UI primitive components.
     - `packages/db`: Database schemas, client singleton, declarative migrations, and seed scripts.
     - `packages/config`: Shared TypeScript, ESLint, and build configurations.
2. **Strict Type Safety & Zero `any` Policy**:
   - Enable `strict: true`, `noImplicitAny: true`, and `strictNullChecks: true`.
   - Validate ALL external inputs, API request bodies, and query parameters with **Zod** schemas before execution.
3. **Frontend & Rendering Guidelines**:
   - Utilize Next.js 15 App Router: default to React Server Components (RSC) for data fetching. Handle mutations through Server Actions with Zod validation. Keep 'use client' directives restricted strictly to interactive leaf components.
4. **Design System & Aesthetics**:
   - Keep every color, radius, shadow and font in a single token file (CSS variables) and consume tokens everywhere; never hardcode hex values in components.
   - Prefer crisp 1px borders and one subtle shadow scale over blurry default shadows. Pair one sans-serif for body/headings with one monospace for tags, badges, metrics, and code.
5. **Data Layer & Reliability**:
   - Write declarative schema definitions with foreign keys, composite indexes on queried filters, and automated timestamp triggers.
   - Use connection pooling and prepared statements for serverless database execution.
---
## 5. STEP-BY-STEP SCAFFOLDING ROADMAP
- **Phase 1: Workspace & Root Config**: Initialize package manager, monorepo configuration (`turbo.json`, `tsconfig.base.json`, `package.json`).
- **Phase 2: Database Schema & Client**: Set up the data layer: client, connection pool, models, and migration scripts.
- **Phase 3: Design Tokens & UI Primitives**: Build accessible `Button`, `Input`, `Card`, `Badge`, and layout wrappers inside `packages/ui`.
- **Phase 4: Core Application Routes & Handlers**: Implement primary authentication, user session handling, and application routes.
- **Phase 5: Quality Assurance & Build Verification**: Run `tsc --noEmit`, ESLint, Prettier, and smoke test suites to ensure zero compilation or runtime errors.
---
## 6. EXECUTION INSTRUCTIONS
1. Review all specifications, architectural guardrails, and stack choices above.
2. Present the full monorepo directory tree structure.
3. Systematically generate the complete, production-ready codebase according to the 5-phase roadmap above — starting with the root workspace setup, followed by the database schema, UI design system package, and full-stack application routes until the repository is fully scaffolded and ready to run.
Scaffolded something with this prompt?
Would you pick this stack for a copy-paste ui component architecture project?

Frequently asked about shadcn/ui

What is shadcn/ui built with?

shadcn/ui is built with React, TypeScript, Tailwind CSS, Radix UI primitives, Next.js for documentation, and a custom Node.js CLI distributed via pnpm.

Why is shadcn/ui not distributed as an npm dependency?

Distributing components as source code allows developers to own their component code completely, customizing styling, behavior, and props without waiting for library updates.

Does shadcn/ui support frameworks other than Next.js?

Yes. The shadcn CLI officially supports Vite, Astro, React Router, TanStack Start, Remix, and Laravel through dedicated project templates in templates/.

What is the component registry in shadcn/ui?

The registry is an open JSON specification that hosts component source code, CSS tokens, and dependencies over HTTP, which the CLI downloads directly into projects.

One email a month: new deep dives and stack trends

New source-audited architectures, head-to-head comparisons and the monthly stack report. No spam, unsubscribe anytime.

use-this-stack.md