Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Build React UIs using shadcn/ui components with Tailwind CSS, Radix primitives, and proper accessibility patterns.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/official-ui-reference.md
1# shadcn/ui Official Reference23> **Security Note**: Components installed via `npx shadcn@latest add` are fetched from the official shadcn registry (`ui.shadcn.com`). When configuring custom registries, only use trusted registry URLs. Always review component source code after installation. Registry URLs in examples below (e.g., `example.com`) are placeholders — replace with your verified private registry URLs.45### Create TanStack Start Project with shadcn/ui67Source: https://ui.shadcn.com/docs/installation/tanstack89Initialize a new TanStack Start project with Tailwind CSS and shadcn/ui add-ons pre-configured. This command sets up the project structure and installs necessary dependencies in one command.1011```bash12npm create @tanstack/start@latest --tailwind --add-ons shadcn13```1415--------------------------------1617### Install All shadcn/ui Components1819Source: https://ui.shadcn.com/docs/installation/tanstack2021Bulk install all available shadcn/ui components into your project at once. This is useful when you want access to the entire component library without adding components individually.2223```bash24npx shadcn@latest add --all25```2627--------------------------------2829### Manually Install Radix UI Select Dependency3031Source: https://ui.shadcn.com/docs/components/select3233This command shows how to install the core `@radix-ui/react-select` primitive package. This manual installation is necessary if you prefer not to use the Shadcn UI CLI for component setup.3435```bash36npm install @radix-ui/react-select37```3839--------------------------------4041### Install Progress Component Dependencies4243Source: https://ui.shadcn.com/docs/components/progress4445This section provides instructions for installing the `Progress` component and its core dependencies. It covers both using the Shadcn UI CLI for automated setup and manual installation via npm for the underlying Radix UI component.4647```bash48npx shadcn@latest add progress49```5051```bash52npm install @radix-ui/react-progress53```5455--------------------------------5657### Serve shadcn Registry with Next.js Development Server5859Source: https://ui.shadcn.com/docs/registry/getting-started6061This command starts the Next.js development server, which will serve your shadcn registry files if your project is configured with Next.js. The registry items will be accessible via specific URLs under `/r/` after the build process.6263```bash64npm run dev65```6667--------------------------------6869### Install shadcn CLI via npm7071Source: https://ui.shadcn.com/docs/registry/getting-started7273This command installs the latest version of the shadcn command-line interface (CLI) globally or as a dev dependency in your project. The CLI is essential for building and managing shadcn component registries and components.7475```bash76npm install shadcn@latest77```7879--------------------------------8081### Create New Laravel Project with React8283Source: https://ui.shadcn.com/docs/installation/laravel8485Initialize a new Laravel project with Inertia and React using the Laravel installer. This command creates a fresh Laravel application with React pre-configured for use with Inertia.js.8687```bash88laravel new my-app --react89```9091--------------------------------9293### Install Shadcn UI Input OTP Component (CLI & Manual)9495Source: https://ui.shadcn.com/docs/components/input-otp9697Provides instructions for adding the Input OTP component to a project. Users can choose between the Shadcn UI CLI for automated setup or manual installation by adding the core `input-otp` dependency via npm and then integrating the component files.9899```bash100npx shadcn@latest add input-otp101```102103```bash104npm install input-otp105```106107--------------------------------108109### Install Aspect Ratio Component via CLI110111Source: https://ui.shadcn.com/docs/components/aspect-ratio112113Installs the aspect-ratio component and its dependencies using the shadcn CLI. This is the quickest installation method that automatically handles dependency installation and file setup.114115```bash116npx shadcn@latest add aspect-ratio117```118119--------------------------------120121### Install Dropdown Menu Component with NPM122123Source: https://ui.shadcn.com/docs/components/dropdown-menu124125Installation command for adding the dropdown menu component to a project using shadcn/ui CLI tool. This is the recommended method for quick setup with automatic dependency management.126127```bash128npx shadcn@latest add dropdown-menu129```130131--------------------------------132133### Define Universal Registry Item for Multi-File Template (shadcn/ui)134135Source: https://ui.shadcn.com/docs/registry/examples136137This JSON configuration defines a shadcn/ui registry item named 'my-custom-start-template' that installs multiple files. It includes two files, each with an explicit target path, demonstrating how to create a universal starter template that can be installed without framework detection or components.json.138139```json140{141"$schema": "https://ui.shadcn.com/schema/registry-item.json",142"name": "my-custom-start-template",143"type": "registry:item",144"dependencies": ["better-auth"],145"files": [146{147"path": "/path/to/file-01.json",148"type": "registry:file",149"target": "~/file-01.json",150"content": "..."151},152{153"path": "/path/to/file-02.vue",154"type": "registry:file",155"target": "~/pages/file-02.vue",156"content": "..."157}158]159}160```161162--------------------------------163164### Add shadcn/ui Button Component165166Source: https://ui.shadcn.com/docs/installation/tanstack167168Install the Button component from shadcn/ui into your TanStack Start project. This command downloads and configures the component in your project's component directory.169170```bash171npx shadcn@latest add button172```173174--------------------------------175176### Install Form Component via Shadcn CLI177178Source: https://ui.shadcn.com/docs/components/form179180This command provides the recommended method for installing the Shadcn UI form component using its command-line interface. Executing this command automates the addition of the form component and its dependencies to your project, simplifying the setup process.181182```bash183npx shadcn@latest add form184```185186--------------------------------187188### Basic Navigation Menu Setup - React TSX189190Source: https://ui.shadcn.com/docs/components/navigation-menu191192Minimal example demonstrating the basic structure of a Navigation Menu with one menu item, trigger, and content link. Serves as a foundation for more complex navigation patterns.193194```typescript195Item OneLink196```197198--------------------------------199200### Multiple Registry Setup with Mixed Authentication201202Source: https://ui.shadcn.com/docs/components-json203204Complete example showing how to configure multiple registries with different authentication methods and parameters. Demonstrates public registries, private registries with bearer tokens, and team registries with versioning and environment variables.205206```json207{208"registries": {209"@shadcn": "https://ui.shadcn.com/r/{name}.json",210"@company-ui": {211"url": "https://registry.company.com/ui/{name}.json",212"headers": {213"Authorization": "Bearer ${COMPANY_TOKEN}"214}215},216"@team": {217"url": "https://team.company.com/{name}.json",218"params": {219"team": "frontend",220"version": "${REGISTRY_VERSION}"221}222}223}224}225```226227--------------------------------228229### Add Component Definition to shadcn registry.json230231Source: https://ui.shadcn.com/docs/registry/getting-started232233This JSON snippet shows how to register a component, like `hello-world`, within the `registry.json` file. It includes metadata such as name, type, title, description, and defines the component's file path and type, ensuring it conforms to the registry item schema.234235```json236{237"$schema": "https://ui.shadcn.com/schema/registry.json",238"name": "acme",239"homepage": "https://acme.com",240"items": [241{242"name": "hello-world",243"type": "registry:block",244"title": "Hello World",245"description": "A simple hello world component.",246"files": [247{248"path": "registry/new-york/hello-world/hello-world.tsx",249"type": "registry:component"250}251]252}253]254}255```256257--------------------------------258259### Install Project Dependencies using npm260261Source: https://ui.shadcn.com/docs/installation/manual262263This bash command installs a set of essential npm packages for the project. These dependencies include utilities for styling (`class-variance-authority`, `clsx`, `tailwind-merge`), icon library (`lucide-react`), and animation effects (`tw-animate-css`).264265```bash266npm install class-variance-authority clsx tailwind-merge lucide-react tw-animate-css267```268269--------------------------------270271### Install React Resizable Panels Dependency Manually272273Source: https://ui.shadcn.com/docs/components/resizable274275This `npm` command installs the core `react-resizable-panels` library, which the `Resizable` component is built upon. It is a prerequisite for manual setup and provides the underlying functionality for resizable UI elements.276277```bash278npm install react-resizable-panels279```280281--------------------------------282283### Install Shadcn UI Skeleton component using CLI284285Source: https://ui.shadcn.com/docs/components/skeleton286287Provides the command-line instruction to add the `Skeleton` component to your project if you are using Shadcn UI's CLI. This automates the setup process for the component.288289```bash290npx shadcn@latest add skeleton291```292293--------------------------------294295### Install Dependencies with pnpm296297Source: https://ui.shadcn.com/docs/blocks298299Installs project dependencies using pnpm package manager. Required before starting development on the block.300301```bash302pnpm install303```304305--------------------------------306307### Install Pagination Component - Bash CLI308309Source: https://ui.shadcn.com/docs/components/pagination310311Command-line installation of the pagination component using the shadcn CLI tool. This is the recommended installation method for projects using shadcn/ui.312313```bash314npx shadcn@latest add pagination315```316317--------------------------------318319### Install Sonner Dependencies Manually320321Source: https://ui.shadcn.com/docs/components/sonner322323Manual installation command that installs Sonner and next-themes packages required for manual setup. Use this approach when you prefer to manually configure the component instead of using the CLI.324325```bash326npm install sonner next-themes327```328329--------------------------------330331### Install Radix UI Separator Dependency via npm332333Source: https://ui.shadcn.com/docs/components/separator334335Install the core Radix UI React Separator dependency required for manual setup. Use this command when manually installing the component instead of using the CLI.336337```bash338npm install @radix-ui/react-separator339```340341--------------------------------342343### Install Checkbox Component via CLI - Bash344345Source: https://ui.shadcn.com/docs/components/checkbox346347Command-line installation method for adding the checkbox component to a shadcn/ui project. Automatically handles component setup and dependency installation.348349```bash350npx shadcn@latest add checkbox351```352353--------------------------------354355### Install Aspect Ratio Dependencies Manually356357Source: https://ui.shadcn.com/docs/components/aspect-ratio358359Manually installs the required Radix UI aspect-ratio dependency. Use this approach when you prefer manual setup or when the CLI method is not suitable for your project.360361```bash362npm install @radix-ui/react-aspect-ratio363```364365--------------------------------366367### Install Input Component via CLI368369Source: https://ui.shadcn.com/docs/components/input370371Install the Input component using the shadcn CLI tool. This command downloads and sets up the component in your project's components directory with all necessary dependencies.372373```bash374npx shadcn@latest add input375```376377--------------------------------378379### Create Remix Project with create-remix380381Source: https://ui.shadcn.com/docs/installation/remix382383Initialize a new Remix project using the create-remix command-line tool. This sets up the basic Remix application structure and dependencies.384385```bash386npx create-remix@latest my-app387```388389--------------------------------390391### Install Shadcn UI Context Menu component via CLI (Bash)392393Source: https://ui.shadcn.com/docs/components/context-menu394395This command demonstrates how to easily add the Shadcn UI Context Menu component to your project using the `npx shadcn@latest add` command-line utility. This method automates the setup and configuration of the component.396397```bash398npx shadcn@latest add context-menu399```400401--------------------------------402403### Install Vaul Dependency for Manual Setup404405Source: https://ui.shadcn.com/docs/components/drawer406407Manually install the Vaul package as a dependency when setting up the Drawer component without the CLI. Vaul is the underlying library that powers the Drawer functionality.408409```bash410npm install vaul411```412413--------------------------------414415### Install Recharts Dependency via npm416417Source: https://ui.shadcn.com/docs/components/chart418419Installs the Recharts library as a project dependency for manual setup. Required when not using the CLI installation method.420421```bash422npm install recharts423```424425--------------------------------426427### Install Shadcn UI Command Component428429Source: https://ui.shadcn.com/docs/components/command430431This section provides instructions for installing the Command menu component, offering both an automated CLI approach and a manual method. The CLI command automatically adds the component, while the manual installation requires installing the 'cmdk' package and then copying the component source code separately.432433```bash434npx shadcn@latest add command435```436437```bash438npm install cmdk439```440441--------------------------------442443### Install Components from Multiple Namespaced Registries444445Source: https://ui.shadcn.com/docs/changelog446447Use the `@`registry/name format to install components from different namespaced registries in a single command. Components are automatically resolved and installed from the correct registry sources.448449```bash450npx shadcn add @acme/button @internal/auth-system451```452453--------------------------------454455### Install Block and Override Primitives in shadcn/ui456457Source: https://ui.shadcn.com/docs/registry/examples458459Configure a registry item to install a block from shadcn/ui and override default primitives with custom implementations from remote registries. This enables centralized dependency management for component hierarchies.460461```json462{463"$schema": "https://ui.shadcn.com/schema/registry-item.json",464"name": "custom-login",465"type": "registry:block",466"registryDependencies": [467"login-01",468"https://example.com/r/button.json",469"https://example.com/r/input.json",470"https://example.com/r/label.json"471]472}473```474475--------------------------------476477### Define Initial shadcn registry.json Structure478479Source: https://ui.shadcn.com/docs/registry/getting-started480481This JSON snippet illustrates the basic structure for a `registry.json` file, which serves as the entry point for a shadcn component registry. It includes the schema reference, registry name, homepage URL, and an empty array for registry items, conforming to the specified registry schema.482483```json484{485"$schema": "https://ui.shadcn.com/schema/registry.json",486"name": "acme",487"homepage": "https://acme.com",488"items": [489// ...490]491}492```493494--------------------------------495496### List All Components from a Registry497498Source: https://ui.shadcn.com/docs/changelog499500Display all available components from a specified namespaced registry. Useful for discovering available components before installation.501502```bash503npx shadcn list @acme504```505506--------------------------------507508### Execute shadcn Registry Build Script509510Source: https://ui.shadcn.com/docs/registry/getting-started511512This command runs the `registry:build` script defined in `package.json`. Executing this script triggers the shadcn CLI to generate the registry JSON files, typically placed in a `public/r` directory by default.513514```bash515npm run registry:build516```517518--------------------------------519520### Install Shadcn UI Select Component via CLI521522Source: https://ui.shadcn.com/docs/components/select523524This command illustrates the quickest way to add the Shadcn UI Select component to your project. It utilizes the `npx shadcn@latest add` utility to automatically install dependencies and configure the component.525526```bash527npx shadcn@latest add select528```529530--------------------------------531532### Configure shadcn Build Script in package.json533534Source: https://ui.shadcn.com/docs/registry/getting-started535536This JSON snippet updates the `package.json` file by adding a `registry:build` script. This script executes the `shadcn build` command, which is used to generate the necessary JSON files for the component registry.537538```json539{540"scripts": {541"registry:build": "shadcn build"542}543}544```545546--------------------------------547548### Install Resources from Namespaced Registries549550Source: https://ui.shadcn.com/docs/components-json551552Install components and resources using the namespace syntax after configuring registries. Supports installing from public registries, private authenticated registries, and multiple resources in a single command.553554```bash555# Install from a configured registry556npx shadcn@latest add @v0/dashboard557558# Install from private registry559npx shadcn@latest add @private/button560561# Install multiple resources562npx shadcn@latest add @acme/header @internal/auth-utils563```564565--------------------------------566567### Install Kbd Component via CLI (shadcn/ui)568569Source: https://ui.shadcn.com/docs/components/kbd570571Provides the command-line interface instruction to add the `Kbd` component to a project using `shadcn@latest`. This is the recommended and easiest method for integrating the component.572573```bash574npx shadcn@latest add kbd575```576577--------------------------------578579### Handle `shadcn/ui` Initialization with React 19 Peer Dependency Prompt (npm)580581Source: https://ui.shadcn.com/docs/react-19582583This `bash` snippet illustrates the interactive prompt from the `shadcn/ui` CLI when initializing a project (`npx shadcn@latest init -d`) while using React 19 with `npm`. It guides users to select a resolution strategy, either `--force` or `--legacy-peer-deps`, to address potential peer dependency conflicts during the shadcn/ui installation process.584585```bash586It looks like you are using React 19.587Some packages may fail to install due to peer dependency issues (see https://ui.shadcn.com/react-19).588589? How would you like to proceed? › - Use arrow-keys. Return to submit.590❯ Use --force591Use --legacy-peer-deps592```593594--------------------------------595596### Install shadcn/ui Label Component via CLI597598Source: https://ui.shadcn.com/docs/components/label599600This `bash` command uses the `shadcn/ui` CLI to quickly add the `Label` component to your project. It automates the process of fetching and integrating the component's files and dependencies, streamlining setup.601602```bash603npx shadcn@latest add label604```605606--------------------------------607608### Add Components to Monorepo Workspace609610Source: https://ui.shadcn.com/docs/monorepo611612Add shadcn/ui components to your monorepo application by navigating to the app directory and running the add command. The CLI automatically determines component type and installs files to correct paths with proper import handling.613614```bash615cd apps/web616npx shadcn@latest add [COMPONENT]617```618619--------------------------------620621### Install Shadcn UI Spinner Component via CLI (Bash)622623Source: https://ui.shadcn.com/docs/components/spinner624625Provides the command-line interface (CLI) instruction to add the Shadcn UI Spinner component to your project. This command automates the setup, including creating the component file and configuring necessary dependencies. Ensure you have the Shadcn UI CLI installed globally or locally before running this command.626627```bash628npx shadcn@latest add spinner629```630631--------------------------------632633### Install Drawer Component via CLI634635Source: https://ui.shadcn.com/docs/components/drawer636637Install the shadcn Drawer component using the CLI tool. This is the recommended installation method that automatically sets up all dependencies and copies necessary files to your project.638639```bash640npx shadcn@latest add drawer641```642643--------------------------------644645### Install Navigation Menu via CLI - shadcn/ui646647Source: https://ui.shadcn.com/docs/components/navigation-menu648649Quick installation command for adding the navigation-menu component to a shadcn/ui project using the CLI tool. Requires Node.js and npm to be installed.650651```bash652npx shadcn@latest add navigation-menu653```654655--------------------------------656657### View Registry Component Before Installation658659Source: https://ui.shadcn.com/docs/changelog660661Preview a component from a namespaced registry without installing it. Displays component code and all dependencies upfront for review.662663```bash664npx shadcn view @acme/auth-system665```666667--------------------------------668669### Install Shadcn Hover Card Component via CLI670671Source: https://ui.shadcn.com/docs/components/hover-card672673This command-line interface (CLI) snippet demonstrates how to add the Shadcn UI Hover Card component to your project using `npx shadcn@latest add`. This method automates the installation and setup process for the component, including copying necessary files and updating configurations.674675```bash676npx shadcn@latest add hover-card677```678679--------------------------------680681### Install Toggle Group Dependencies via npm682683Source: https://ui.shadcn.com/docs/components/toggle-group684685Install the required Radix UI toggle group dependency manually using npm. Required for projects that prefer manual component setup.686687```bash688npm install @radix-ui/react-toggle-group689```690691--------------------------------692693### Import and Use Button Component in TanStack Start694695Source: https://ui.shadcn.com/docs/installation/tanstack696697Import the Button component from the components/ui directory and render it in your application. This example shows basic usage within a React functional component in the app/routes/index.tsx file.698699```tsx700import { Button } from "@/components/ui/button"701702function App() {703return (704705706Click me707708)709}710```711712--------------------------------713714### Install Carousel Component via CLI715716Source: https://ui.shadcn.com/docs/components/carousel717718shadcn/ui CLI command to automatically install and configure the carousel component with all dependencies and file setup. Simplest method for adding the carousel to your project.719720```bash721npx shadcn@latest add carousel722```723724--------------------------------725726### Install Resizable Component using Shadcn CLI727728Source: https://ui.shadcn.com/docs/components/resizable729730This command-line interface (CLI) snippet shows how to add the `resizable` component to a project using the `shadcn` utility. It simplifies the installation process by automatically configuring the component and its dependencies.731732```bash733npx shadcn@latest add resizable734```735736--------------------------------737738### Install Menubar via CLI - Bash739740Source: https://ui.shadcn.com/docs/components/menubar741742Command to install the menubar component using the shadcn package manager CLI. This is the quickest installation method that automatically downloads and configures the component for your project.743744```bash745npx shadcn@latest add menubar746```747748--------------------------------749750### Install Radio Group via CLI - Bash751752Source: https://ui.shadcn.com/docs/components/radio-group753754Command-line interface installation method for adding the radio-group component to a shadcn/ui project. This is the recommended approach as it automatically handles file copying and setup.755756```bash757npx shadcn@latest add radio-group758```759760--------------------------------761762### Define reusable registry block with components763764Source: https://ui.shadcn.com/docs/registry/examples765766Create a registry block item that bundles multiple related files (pages and components) with their dependencies. This block specifies registry dependencies on other components and defines file paths with content references for installation into target locations in the project structure.767768```json769{770"$schema": "https://ui.shadcn.com/schema/registry-item.json",771"name": "login-01",772"type": "registry:block",773"description": "A simple login form.",774"registryDependencies": ["button", "card", "input", "label"],775"files": [776{777"path": "blocks/login-01/page.tsx",778"content": "import { LoginForm } ...",779"type": "registry:page",780"target": "app/login/page.tsx"781},782{783"path": "blocks/login-01/components/login-form.tsx",784"content": "...",785"type": "registry:component"786}787]788}789```790791--------------------------------792793### Install Radix UI Context Menu dependency manually (Bash)794795Source: https://ui.shadcn.com/docs/components/context-menu796797This command is part of the manual installation process, showing how to install the core `@radix-ui/react-context-menu` dependency using npm. This dependency provides the fundamental building blocks for the Shadcn UI Context Menu.798799```bash800npm install @radix-ui/react-context-menu801```802803--------------------------------804805### Install Native Select component via CLI806807Source: https://ui.shadcn.com/docs/components/native-select808809Use the shadcn CLI to easily add the Native Select component to your project. This command will scaffold the necessary files and update dependencies automatically, streamlining the setup process.810811```bash812npx shadcn@latest add native-select813```814815--------------------------------816817### Install Empty Component via CLI818819Source: https://ui.shadcn.com/docs/components/empty820821Command to install the Empty component using the shadcn package manager. Automatically adds the component and its dependencies to the project.822823```bash824npx shadcn@latest add empty825```826827--------------------------------828829### Install shadcn Table component and TanStack React Table830831Source: https://ui.shadcn.com/docs/components/data-table832833Installation commands to add the Table component from shadcn and the TanStack React Table dependency to your project. These are prerequisites for building data tables with this guide.834835```bash836npx shadcn@latest add table837```838839```bash840npm install @tanstack/react-table841```842843--------------------------------844845### Install Switch Component via CLI846847Source: https://ui.shadcn.com/docs/components/switch848849Command-line installation method for adding the Switch component to a shadcn/ui project. Uses the official CLI tool to automatically download and configure the component with all required dependencies.850851```bash852npx shadcn@latest add switch853```854855--------------------------------856857### Start Development Server with pnpm858859Source: https://ui.shadcn.com/docs/blocks860861Starts the development server for the www application at http://localhost:3333. Enables live preview of blocks during development.862863```bash864pnpm www:dev865```866867--------------------------------868869### Install Shadcn UI Badge component via CLI (Bash)870871Source: https://ui.shadcn.com/docs/components/badge872873This command line interface snippet demonstrates how to add the Shadcn UI Badge component to a project using the `npx shadcn` utility. It simplifies the setup process by automating the component file generation.874875```bash876npx shadcn@latest add badge877```878879--------------------------------880881### Interactive Configuration Questions for shadcn init882883Source: https://ui.shadcn.com/docs/changelog884885Configuration prompts displayed during the shadcn init setup process. Users answer questions about style, base color, CSS file location, CSS variables usage, Tailwind config path, component/utils import aliases, and React Server Components support.886887```text888Which style would you like to use? › Default889Which color would you like to use as base color? › Slate890Where is your global CSS file? › › app/globals.css891Do you want to use CSS variables for colors? › no / yes892Where is your tailwind.config.js located? › tailwind.config.js893Configure the import alias for components: › @/components894Configure the import alias for utils: › @/lib/utils895Are you using React Server Components? › no / yes896```897898--------------------------------899900### Item Component Installation - Bash901902Source: https://ui.shadcn.com/docs/components/item903904CLI command to install the Item component from shadcn. Requires Node.js and npm/pnpm package manager.905906```bash907npx shadcn@latest add item908```909910--------------------------------911912### CLI Command: Initialize Project from Local File913914Source: https://ui.shadcn.com/docs/changelog915916The `shadcn` CLI now supports initializing projects from local JSON files. This command allows users to set up a project using a local `template.json`, enabling zero-setup development and local testing of registry items.917918```bash919npx shadcn init ./template.json920```921922--------------------------------923924### Install Tailwind CSS and Autoprefixer925926Source: https://ui.shadcn.com/docs/installation/remix927928Install Tailwind CSS and Autoprefixer as development dependencies to enable styling support for shadcn/ui components in your Remix project.929930```bash931npm install -D tailwindcss@latest autoprefixer@latest932```933934--------------------------------935936### Install Tooltip Dependencies via npm937938Source: https://ui.shadcn.com/docs/components/tooltip939940Manual installation of the Radix UI tooltip dependency. Required when not using the shadcn CLI installation method. Install this package before copying the tooltip component source.941942```bash943npm install @radix-ui/react-tooltip944```945946--------------------------------947948### Install Shadcn UI Dialog component using CLI or npm949950Source: https://ui.shadcn.com/docs/components/dialog951952Instructions for installing the Shadcn UI Dialog component. Provides options for using the Shadcn CLI to add the component or manually installing the underlying Radix UI dependency.953954```bash955npx shadcn@latest add dialog956```957958```bash959npm install @radix-ui/react-dialog960```961962--------------------------------963964### Install Toggle Component via CLI965966Source: https://ui.shadcn.com/docs/components/toggle967968Install the Toggle component using the shadcn CLI tool. This command downloads and sets up the component with all dependencies in your project.969970```bash971npx shadcn@latest add toggle972```973974--------------------------------975976### Install Sheet Component via CLI977978Source: https://ui.shadcn.com/docs/components/sheet979980Command to install the Sheet component and its dependencies using the shadcn CLI. This is the recommended installation method for projects using shadcn/ui.981982```bash983npx shadcn@latest add sheet984```985986--------------------------------987988### Install Shadcn UI Popover component989990Source: https://ui.shadcn.com/docs/components/popover991992These commands provide two methods for installing the Popover component into your project. The CLI method uses `npx shadcn` to add the component automatically, while the manual method involves installing the core Radix UI dependency via npm and then copying the component source code. Ensure your project is set up to use shadcn/ui before installing components.993994```bash995npx shadcn@latest add popover996```997998```bash999npm install @radix-ui/react-popover1000```10011002--------------------------------10031004### Install Sonner via CLI10051006Source: https://ui.shadcn.com/docs/components/sonner10071008Command-line installation method using shadcn-cli to add the Sonner component to a project. This is the quickest way to set up Sonner with all necessary dependencies.10091010```bash1011npx shadcn@latest add sonner1012```10131014--------------------------------10151016### Complete Bar Chart with XAxis Implementation10171018Source: https://ui.shadcn.com/docs/components/chart10191020Full React component example using the 'use client' directive for client-side rendering. Demonstrates a complete bar chart setup with sample data for desktop and mobile metrics across six months, including XAxis configuration with custom tick formatting.10211022```tsx1023"use client"10241025import { Bar, BarChart, CartesianGrid, XAxis } from "recharts"10261027import { ChartConfig, ChartContainer } from "@/components/ui/chart"10281029const chartData = [1030{ month: "January", desktop: 186, mobile: 80 },1031{ month: "February", desktop: 305, mobile: 200 },1032{ month: "March", desktop: 237, mobile: 120 },1033{ month: "April", desktop: 73, mobile: 190 },1034{ month: "May", desktop: 209, mobile: 130 },1035{ month: "June", desktop: 214, mobile: 140 },1036]10371038const chartConfig = {1039desktop: {1040label: "Desktop",1041color: "#2563eb",1042},1043mobile: {1044label: "Mobile",1045color: "#60a5fa",1046},1047} satisfies ChartConfig10481049export function Component() {1050return (1051value.slice(0, 3)}1052/>10531054)1055}1056```10571058--------------------------------10591060### Environment Variables Setup10611062Source: https://ui.shadcn.com/docs/registry/authentication10631064Set registry authentication token in .env.local file. This stores the secret token that will be used for Bearer authentication when accessing private component registries.10651066```bash1067REGISTRY_TOKEN=your_secret_token_here1068```10691070--------------------------------10711072### Install Table Component via CLI10731074Source: https://ui.shadcn.com/docs/components/table10751076CLI command to install the shadcn/ui Table component using npx. This automatically adds the component to your project.10771078```bash1079npx shadcn@latest add table1080```10811082--------------------------------10831084### Install next-themes package10851086Source: https://ui.shadcn.com/docs/dark-mode/next10871088This command installs the `next-themes` package, a crucial dependency for implementing dark mode functionality in Next.js applications.10891090```bash1091npm install next-themes1092```10931094--------------------------------10951096### Install Separator Component via CLI10971098Source: https://ui.shadcn.com/docs/components/separator10991100Install the Separator component using the shadcn CLI tool. This command automatically downloads and sets up the component in your project with all required dependencies.11011102```bash1103npx shadcn@latest add separator1104```11051106--------------------------------11071108### Install Menubar Dependencies - Bash11091110Source: https://ui.shadcn.com/docs/components/menubar11111112Manual installation command for the Radix UI menubar dependency. Use this when manually setting up the component instead of using the CLI. Requires Node.js package manager (npm).11131114```bash1115npm install @radix-ui/react-menubar1116```11171118--------------------------------11191120### Install Tooltip via shadcn CLI11211122Source: https://ui.shadcn.com/docs/components/tooltip11231124Command-line installation method for adding the Tooltip component to a shadcn/ui project. This is the recommended approach for quickly adding pre-configured component files.11251126```bash1127npx shadcn@latest add tooltip1128```11291130--------------------------------11311132### Install Slider Component via CLI11331134Source: https://ui.shadcn.com/docs/components/slider11351136Command-line installation method for adding the Slider component to a shadcn/ui project. This is the quickest way to install the component and its dependencies.11371138```bash1139npx shadcn@latest add slider1140```11411142--------------------------------11431144### Install Shadcn Alert component via CLI11451146Source: https://ui.shadcn.com/docs/components/alert11471148This command provides a quick way to add the Shadcn Alert component to your project using the command-line interface. It leverages `npx` to execute the `shadcn` utility for component installation.11491150```bash1151npx shadcn@latest add alert1152```11531154--------------------------------11551156### Create a Basic shadcn Component in TSX11571158Source: https://ui.shadcn.com/docs/registry/getting-started11591160This TypeScript React (TSX) code defines a simple `HelloWorld` component that renders a button with 'Hello World' text. It imports the `Button` component from a local UI library, demonstrating how to structure a component intended for the shadcn registry.11611162```tsx1163import { Button } from "@/components/ui/button"11641165export function HelloWorld() {1166return Hello World1167}1168```11691170--------------------------------11711172### Install Radix UI Switch Dependency11731174Source: https://ui.shadcn.com/docs/components/switch11751176NPM installation command for the Radix UI switch primitive dependency. Required when manually installing the Switch component without using the shadcn CLI tool.11771178```bash1179npm install @radix-ui/react-switch1180```11811182--------------------------------11831184### Button Size Variants Example11851186Source: https://ui.shadcn.com/docs/components/button11871188Comprehensive example showing all Button size options: sm, icon-sm, default, icon, lg, and icon-lg. Demonstrates text and icon buttons at different sizes.11891190```typescript1191import { ArrowUpRightIcon } from "lucide-react"11921193import { Button } from "@/components/ui/button"11941195export function ButtonSize() {1196return (119711981199Small120012011202Default12031204Large120512061207)1208}1209```12101211--------------------------------12121213### Create custom style extending shadcn/ui12141215Source: https://ui.shadcn.com/docs/registry/examples12161217Define a custom registry style that extends shadcn/ui by installing dependencies, adding registry dependencies (components and remote blocks), and configuring CSS variables for fonts and brand colors in light and dark modes. This configuration is applied when running `npx shadcn init`.12181219```json1220{1221"$schema": "https://ui.shadcn.com/schema/registry-item.json",1222"name": "example-style",1223"type": "registry:style",1224"dependencies": ["@tabler/icons-react"],1225"registryDependencies": [1226"login-01",1227"calendar",1228"https://example.com/r/editor.json"1229],1230"cssVars": {1231"theme": {1232"font-sans": "Inter, sans-serif"1233},1234"light": {1235"brand": "20 14.3% 4.1%"1236},1237"dark": {1238"brand": "20 14.3% 4.1%"1239}1240}1241}1242```12431244--------------------------------12451246### Example Shadcn UI Registry Configuration (JSON)12471248Source: https://ui.shadcn.com/docs/registry/registry-index12491250This JSON configuration demonstrates a valid structure for a Shadcn UI registry. It includes a schema reference, the registry's name and homepage, and an array of items, each representing a component or example with its type, title, description, and associated file paths. This structure adheres to the specified registry schema requirements.12511252```json1253{1254"$schema": "https://ui.shadcn.com/schema/registry.json",1255"name": "acme",1256"homepage": "https://acme.com",1257"items": [1258{1259"name": "login-form",1260"type": "registry:component",1261"title": "Login Form",1262"description": "A login form component.",1263"files": [1264{1265"path": "registry/new-york/auth/login-form.tsx",1266"type": "registry:component"1267}1268]1269},1270{1271"name": "example-login-form",1272"type": "registry:component",1273"title": "Example Login Form",1274"description": "An example showing how to use the login form component.",1275"files": [1276{1277"path": "registry/new-york/examples/example-login-form.tsx",1278"type": "registry:component"1279}1280]1281}1282]1283}1284```12851286--------------------------------12871288### Manually install Radix UI Alert Dialog dependency with npm12891290Source: https://ui.shadcn.com/docs/components/alert-dialog12911292This `bash` command is used for manual installation of the Shadcn UI Alert Dialog component, specifically for installing its underlying Radix UI primitive. It adds the `@radix-ui/react-alert-dialog` package as a dependency to your project. This step is required before copying the component source code.12931294```bash1295npm install @radix-ui/react-alert-dialog1296```12971298--------------------------------12991300### Component Diff Output Example13011302Source: https://ui.shadcn.com/docs/changelog13031304Example output showing differences in a component's code. The diff displays additions and removals, showing what has changed in the upstream repository.13051306```diff1307const alertVariants = cva(1308- "relative w-full rounded-lg border",1309+ "relative w-full pl-12 rounded-lg border"1310)1311```13121313--------------------------------13141315### Install Button Dependencies via npm13161317Source: https://ui.shadcn.com/docs/components/button13181319Manual installation of required dependencies for the Button component. Install the `@`radix-ui/react-slot package which provides slot composition functionality.13201321```bash1322npm install @radix-ui/react-slot1323```13241325--------------------------------13261327### CLI Error: Missing Registry Environment Variables13281329Source: https://ui.shadcn.com/docs/changelog13301331This example demonstrates the CLI's helpful error for missing environment variables required by a registry. It explicitly lists the necessary variables, like `REGISTRY_TOKEN`, and instructs users to set them in `.env` or `.env.local` files.13321333```txt1334Registry "@private" requires the following environment variables:1335• REGISTRY_TOKEN13361337Set the required environment variables to your .env or .env.local file.1338```13391340--------------------------------13411342### Install Multiple Resources from Different Namespaces13431344Source: https://ui.shadcn.com/docs/registry/namespace13451346Install multiple resources from different namespaced registries in a single command. Supports combining resources from UI components, libraries, and AI prompts across various registries.13471348```bash1349npx shadcn@latest add @acme/header @lib/auth-utils @ai/chatbot-rules1350```13511352--------------------------------13531354### Define Universal Registry Item for ESLint Configuration (shadcn/ui)13551356Source: https://ui.shadcn.com/docs/registry/examples13571358This JSON configuration defines a shadcn/ui registry item named 'my-eslint-config' for a custom ESLint configuration. It specifies a single file with an explicit target path (~/.eslintrc.json), enabling universal installation of the ESLint config file without framework dependencies.13591360```json1361{1362"$schema": "https://ui.shadcn.com/schema/registry-item.json",1363"name": "my-eslint-config",1364"type": "registry:item",1365"files": [1366{1367"path": "/path/to/your/registry/default/custom-eslint.json",1368"type": "registry:file",1369"target": "~/.eslintrc.json",1370"content": "..."1371}1372]1373}1374```13751376--------------------------------13771378### Configure Plugin with NPM Dependencies in shadcn UI13791380Source: https://ui.shadcn.com/docs/registry/examples13811382Shows how to include external npm packages as dependencies when using Tailwind CSS plugins. The `dependencies` array declares required packages, while the `css` object configures both the plugin and custom CSS layers. This pattern ensures all required packages are installed before the component is used.13831384```json1385{1386"$schema": "https://ui.shadcn.com/schema/registry-item.json",1387"name": "typography-component",1388"type": "registry:item",1389"dependencies": ["@tailwindcss/typography"],1390"css": {1391"@plugin "@tailwindcss/typography"": {},1392"@layer components": {1393".prose": {1394"max-width": "65ch"1395}1396}1397}1398}1399```14001401--------------------------------14021403### Install Shadcn Accordion Component (bash)14041405Source: https://ui.shadcn.com/docs/components/accordion14061407This snippet provides two methods for installing the Shadcn UI Accordion component. Users can either add the component directly using the Shadcn CLI or manually install the underlying Radix UI dependency via npm. Both methods prepare the project for using the Accordion component by adding necessary files and packages.14081409```bash1410npx shadcn@latest add accordion1411```14121413```bash1414npm install @radix-ui/react-accordion1415```14161417--------------------------------14181419### Install Navigation Menu Dependencies - npm14201421Source: https://ui.shadcn.com/docs/components/navigation-menu14221423Manual installation of required Radix UI navigation menu dependency. Use this approach when manually setting up the component instead of using the CLI.14241425```bash1426npm install @radix-ui/react-navigation-menu1427```14281429--------------------------------14301431### Configure Secure Custom Registry with Authorization Headers (JSON)14321433Source: https://ui.shadcn.com/docs/registry/namespace14341435Provides an example of configuring a custom company registry in `components.json`, including a URL and authorization headers with an environment variable. This setup demonstrates best practices for securely connecting to private registries, requiring explicit authentication.14361437```json1438{1439"@company": {1440"url": "https://registry.company.com/v1/{name}.json",1441"headers": {1442"Authorization": "Bearer ${COMPANY_TOKEN}",1443"X-Registry-Version": "1.0"1444}1445}1446}1447```14481449--------------------------------14501451### Create components.json Configuration File for shadcn/ui14521453Source: https://ui.shadcn.com/docs/installation/manual14541455This JSON configuration file sets up the shadcn/ui component library with New York style, TypeScript/TSX support, Tailwind CSS styling with CSS variables, and path aliases for easier imports. Place this file in the root of your project directory to enable component scaffolding and configuration.14561457```json1458{1459"$schema": "https://ui.shadcn.com/schema.json",1460"style": "new-york",1461"rsc": false,1462"tsx": true,1463"tailwind": {1464"config": "",1465"css": "src/styles/globals.css",1466"baseColor": "neutral",1467"cssVariables": true,1468"prefix": ""1469},1470"aliases": {1471"components": "@/components",1472"utils": "@/lib/utils",1473"ui": "@/components/ui",1474"lib": "@/lib",1475"hooks": "@/hooks"1476},1477"iconLibrary": "lucide"1478}1479```14801481--------------------------------14821483### Install Button Component via CLI14841485Source: https://ui.shadcn.com/docs/components/button14861487Quick installation of the Button component using the shadcn CLI tool. Automatically adds the button component and its dependencies to your project.14881489```bash1490npx shadcn@latest add button1491```14921493--------------------------------14941495### Install Tabs Dependencies via NPM - Bash14961497Source: https://ui.shadcn.com/docs/components/tabs14981499Manual npm installation of the Radix UI Tabs dependency. Use this method when manually adding the tabs component instead of using the CLI installer.15001501```bash1502npm install @radix-ui/react-tabs1503```15041505--------------------------------15061507### Install Checkbox Dependencies - Bash15081509Source: https://ui.shadcn.com/docs/components/checkbox15101511Manual installation command for the Radix UI checkbox dependency. Required when manually setting up the checkbox component without using the CLI.15121513```bash1514npm install @radix-ui/react-checkbox1515```15161517--------------------------------15181519### Add Components with add Command15201521Source: https://ui.shadcn.com/docs/cli15221523The add command installs specific components and their dependencies into your project. It supports single or multiple component installation, file overwriting, and path customization.15241525```bash1526npx shadcn@latest add [component]1527```15281529```bash1530Usage: shadcn add [options] [components...]15311532add a component to your project15331534Arguments:1535components name, url or local path to component15361537Options:1538-y, --yes skip confirmation prompt. (default: false)1539-o, --overwrite overwrite existing files. (default: false)1540-c, --cwd the working directory. defaults to the current directory.1541-a, --all add all available components (default: false)1542-p, --path the path to add the component to.1543-s, --silent mute output. (default: false)1544--src-dir use the src directory when creating a new project. (default: false)1545--no-src-dir do not use the src directory when creating a new project.1546--css-variables use css variables for theming. (default: true)1547--no-css-variables do not use css variables for theming.1548-h, --help display help for command1549```15501551--------------------------------15521553### Create new React project with Vite15541555Source: https://ui.shadcn.com/docs/installation/vite15561557Initializes a new React project using Vite. This command uses the latest version of Vite and allows selecting the 'React + TypeScript' template during the interactive setup process.15581559```bash1560npm create vite@latest1561```15621563--------------------------------15641565### Manually Install Radix UI Label npm Dependency15661567Source: https://ui.shadcn.com/docs/components/label15681569For manual installation of the `shadcn/ui` Label component, this `npm` command installs its core dependency, `@radix-ui/react-label`. This step is followed by copying the component's source code into your project and updating import paths.15701571```bash1572npm install @radix-ui/react-label1573```15741575--------------------------------15761577### Install Single Resource from Namespaced Registry15781579Source: https://ui.shadcn.com/docs/registry/namespace15801581Install a single resource from a configured namespace using the shadcn CLI. The syntax uses `@`namespace/resource-name format to specify which registry and resource to install.15821583```bash1584npx shadcn@latest add @v0/dashboard1585```15861587--------------------------------15881589### Add UI Components with add Command15901591Source: https://ui.shadcn.com/docs/changelog15921593Use the add command to install UI components from shadcn into your project. The CLI automatically resolves dependencies, formats components based on your components.json configuration, and installs them with correct import paths and styling methods.15941595```bash1596npx shadcn@latest add1597```15981599--------------------------------16001601### Install Button Group via CLI - Bash16021603Source: https://ui.shadcn.com/docs/components/button-group16041605Command-line installation script for the Button Group component using the shadcn package manager. This is the recommended installation method that automatically sets up the component with dependencies.16061607```bash1608npx shadcn@latest add button-group1609```16101611--------------------------------16121613### Radix UI Migration: Import Path Update Example16141615Source: https://ui.shadcn.com/docs/changelog16161617This `diff` example illustrates the effect of the `radix` migration command on component files. It shows how an import for `AlertDialogPrimitive` is changed from `@radix-ui/react-dialog` to the new `radix-ui` package.16181619```diff1620- import * as AlertDialogPrimitive from "@radix-ui/react-dialog"1621+ import { AlertDialog as AlertDialogPrimitive } from "radix-ui"1622```16231624--------------------------------16251626### Initialize shadcn Project with init Command16271628Source: https://ui.shadcn.com/docs/cli16291630The init command sets up a new shadcn project by installing dependencies, adding the cn utility, and configuring CSS variables. It supports template selection, base color configuration, and directory structure options.16311632```bash1633npx shadcn@latest init1634```16351636```bash1637Usage: shadcn init [options] [components...]16381639initialize your project and install dependencies16401641Arguments:1642components name, url or local path to component16431644Options:1645-t, --template the template to use. (next, next-monorepo)1646-b, --base-color the base color to use. (neutral, gray, zinc, stone, slate)1647-y, --yes skip confirmation prompt. (default: true)1648-f, --force force overwrite of existing configuration. (default: false)1649-c, --cwd the working directory. defaults to the current directory.1650-s, --silent mute output. (default: false)1651--src-dir use the src directory when creating a new project. (default: false)1652--no-src-dir do not use the src directory when creating a new project.1653--css-variables use css variables for theming. (default: true)1654--no-css-variables do not use css variables for theming.1655--no-base-style do not install the base shadcn style1656-h, --help display help for command1657```16581659--------------------------------16601661### Install Dropdown Menu Dependencies16621663Source: https://ui.shadcn.com/docs/components/dropdown-menu16641665NPM installation command for the Radix UI dropdown menu primitive dependency. Required when manually adding the component without using the shadcn/ui CLI tool.16661667```bash1668npm install @radix-ui/react-dropdown-menu1669```16701671--------------------------------16721673### Install Toggle Component Dependencies Manually16741675Source: https://ui.shadcn.com/docs/components/toggle16761677Install the required Radix UI toggle dependency manually for projects that don't use the shadcn CLI. This is the first step when manually setting up the Toggle component.16781679```bash1680npm install @radix-ui/react-toggle1681```16821683--------------------------------16841685### Add Components with Shadcn CLI16861687Source: https://ui.shadcn.com/docs/changelog16881689This command demonstrates how to use the Shadcn CLI to add a specific component from a registry to your project. It automatically handles installation and updates the project's 'components.json' file.16901691```bash1692npx shadcn add @ai-elements/prompt-input1693```16941695--------------------------------16961697### Initialize MCP Server for shadcn Registries16981699Source: https://ui.shadcn.com/docs/changelog17001701Set up MCP (Model Context Protocol) server for all configured registries with zero configuration. Enables integration with MCP clients for AI-assisted component discovery and installation.17021703```bash1704npx shadcn@latest mcp init1705```17061707--------------------------------17081709### Install Chart Component via CLI17101711Source: https://ui.shadcn.com/docs/components/chart17121713Installs the chart.tsx component using shadcn's CLI tool. This command automatically sets up the chart component file in the project structure.17141715```bash1716npx shadcn@latest add chart1717```17181719--------------------------------17201721### Install Card Component via CLI - shadcn17221723Source: https://ui.shadcn.com/docs/components/card17241725Install the Card component using the shadcn CLI tool. This command downloads and integrates the Card component into your project's components directory.17261727```bash1728npx shadcn@latest add card1729```