xonecas.io
556
Bn

bees-nest / files

bees-nest / .opencode / skills / shadcn-ui / official-ui-reference.md

50.6 KB
1### Create TanStack Start Project with shadcn/ui
2
3Source: https://ui.shadcn.com/docs/installation/tanstack
4
5Initialize 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.
6
7```bash
8npm create @tanstack/start@latest --tailwind --add-ons shadcn
9```
10
11--------------------------------
12
13### Install All shadcn/ui Components
14
15Source: https://ui.shadcn.com/docs/installation/tanstack
16
17Bulk 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.
18
19```bash
20npx shadcn@latest add --all
21```
22
23--------------------------------
24
25### Manually Install Radix UI Select Dependency
26
27Source: https://ui.shadcn.com/docs/components/select
28
29This 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.
30
31```bash
32npm install @radix-ui/react-select
33```
34
35--------------------------------
36
37### Install Progress Component Dependencies
38
39Source: https://ui.shadcn.com/docs/components/progress
40
41This 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.
42
43```bash
44npx shadcn@latest add progress
45```
46
47```bash
48npm install @radix-ui/react-progress
49```
50
51--------------------------------
52
53### Serve shadcn Registry with Next.js Development Server
54
55Source: https://ui.shadcn.com/docs/registry/getting-started
56
57This 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.
58
59```bash
60npm run dev
61```
62
63--------------------------------
64
65### Install shadcn CLI via npm
66
67Source: https://ui.shadcn.com/docs/registry/getting-started
68
69This 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.
70
71```bash
72npm install shadcn@latest
73```
74
75--------------------------------
76
77### Create New Laravel Project with React
78
79Source: https://ui.shadcn.com/docs/installation/laravel
80
81Initialize 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.
82
83```bash
84laravel new my-app --react
85```
86
87--------------------------------
88
89### Install Shadcn UI Input OTP Component (CLI & Manual)
90
91Source: https://ui.shadcn.com/docs/components/input-otp
92
93Provides 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.
94
95```bash
96npx shadcn@latest add input-otp
97```
98
99```bash
100npm install input-otp
101```
102
103--------------------------------
104
105### Install Aspect Ratio Component via CLI
106
107Source: https://ui.shadcn.com/docs/components/aspect-ratio
108
109Installs 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.
110
111```bash
112npx shadcn@latest add aspect-ratio
113```
114
115--------------------------------
116
117### Install Dropdown Menu Component with NPM
118
119Source: https://ui.shadcn.com/docs/components/dropdown-menu
120
121Installation 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.
122
123```bash
124npx shadcn@latest add dropdown-menu
125```
126
127--------------------------------
128
129### Define Universal Registry Item for Multi-File Template (shadcn/ui)
130
131Source: https://ui.shadcn.com/docs/registry/examples
132
133This 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.
134
135```json
136{
137 "$schema": "https://ui.shadcn.com/schema/registry-item.json",
138 "name": "my-custom-start-template",
139 "type": "registry:item",
140 "dependencies": ["better-auth"],
141 "files": [
142 {
143 "path": "/path/to/file-01.json",
144 "type": "registry:file",
145 "target": "~/file-01.json",
146 "content": "..."
147 },
148 {
149 "path": "/path/to/file-02.vue",
150 "type": "registry:file",
151 "target": "~/pages/file-02.vue",
152 "content": "..."
153 }
154 ]
155}
156```
157
158--------------------------------
159
160### Add shadcn/ui Button Component
161
162Source: https://ui.shadcn.com/docs/installation/tanstack
163
164Install the Button component from shadcn/ui into your TanStack Start project. This command downloads and configures the component in your project's component directory.
165
166```bash
167npx shadcn@latest add button
168```
169
170--------------------------------
171
172### Install Form Component via Shadcn CLI
173
174Source: https://ui.shadcn.com/docs/components/form
175
176This 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.
177
178```bash
179npx shadcn@latest add form
180```
181
182--------------------------------
183
184### Basic Navigation Menu Setup - React TSX
185
186Source: https://ui.shadcn.com/docs/components/navigation-menu
187
188Minimal 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.
189
190```typescript
191Item OneLink
192```
193
194--------------------------------
195
196### Multiple Registry Setup with Mixed Authentication
197
198Source: https://ui.shadcn.com/docs/components-json
199
200Complete 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.
201
202```json
203{
204 "registries": {
205 "@shadcn": "https://ui.shadcn.com/r/{name}.json",
206 "@company-ui": {
207 "url": "https://registry.company.com/ui/{name}.json",
208 "headers": {
209 "Authorization": "Bearer ${COMPANY_TOKEN}"
210 }
211 },
212 "@team": {
213 "url": "https://team.company.com/{name}.json",
214 "params": {
215 "team": "frontend",
216 "version": "${REGISTRY_VERSION}"
217 }
218 }
219 }
220}
221```
222
223--------------------------------
224
225### Add Component Definition to shadcn registry.json
226
227Source: https://ui.shadcn.com/docs/registry/getting-started
228
229This 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.
230
231```json
232{
233 "$schema": "https://ui.shadcn.com/schema/registry.json",
234 "name": "acme",
235 "homepage": "https://acme.com",
236 "items": [
237 {
238 "name": "hello-world",
239 "type": "registry:block",
240 "title": "Hello World",
241 "description": "A simple hello world component.",
242 "files": [
243 {
244 "path": "registry/new-york/hello-world/hello-world.tsx",
245 "type": "registry:component"
246 }
247 ]
248 }
249 ]
250}
251```
252
253--------------------------------
254
255### Install Project Dependencies using npm
256
257Source: https://ui.shadcn.com/docs/installation/manual
258
259This 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`).
260
261```bash
262npm install class-variance-authority clsx tailwind-merge lucide-react tw-animate-css
263```
264
265--------------------------------
266
267### Install React Resizable Panels Dependency Manually
268
269Source: https://ui.shadcn.com/docs/components/resizable
270
271This `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.
272
273```bash
274npm install react-resizable-panels
275```
276
277--------------------------------
278
279### Install Shadcn UI Skeleton component using CLI
280
281Source: https://ui.shadcn.com/docs/components/skeleton
282
283Provides 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.
284
285```bash
286npx shadcn@latest add skeleton
287```
288
289--------------------------------
290
291### Install Dependencies with pnpm
292
293Source: https://ui.shadcn.com/docs/blocks
294
295Installs project dependencies using pnpm package manager. Required before starting development on the block.
296
297```bash
298pnpm install
299```
300
301--------------------------------
302
303### Install Pagination Component - Bash CLI
304
305Source: https://ui.shadcn.com/docs/components/pagination
306
307Command-line installation of the pagination component using the shadcn CLI tool. This is the recommended installation method for projects using shadcn/ui.
308
309```bash
310npx shadcn@latest add pagination
311```
312
313--------------------------------
314
315### Install Sonner Dependencies Manually
316
317Source: https://ui.shadcn.com/docs/components/sonner
318
319Manual 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.
320
321```bash
322npm install sonner next-themes
323```
324
325--------------------------------
326
327### Install Radix UI Separator Dependency via npm
328
329Source: https://ui.shadcn.com/docs/components/separator
330
331Install the core Radix UI React Separator dependency required for manual setup. Use this command when manually installing the component instead of using the CLI.
332
333```bash
334npm install @radix-ui/react-separator
335```
336
337--------------------------------
338
339### Install Checkbox Component via CLI - Bash
340
341Source: https://ui.shadcn.com/docs/components/checkbox
342
343Command-line installation method for adding the checkbox component to a shadcn/ui project. Automatically handles component setup and dependency installation.
344
345```bash
346npx shadcn@latest add checkbox
347```
348
349--------------------------------
350
351### Install Aspect Ratio Dependencies Manually
352
353Source: https://ui.shadcn.com/docs/components/aspect-ratio
354
355Manually 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.
356
357```bash
358npm install @radix-ui/react-aspect-ratio
359```
360
361--------------------------------
362
363### Install Input Component via CLI
364
365Source: https://ui.shadcn.com/docs/components/input
366
367Install 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.
368
369```bash
370npx shadcn@latest add input
371```
372
373--------------------------------
374
375### Create Remix Project with create-remix
376
377Source: https://ui.shadcn.com/docs/installation/remix
378
379Initialize a new Remix project using the create-remix command-line tool. This sets up the basic Remix application structure and dependencies.
380
381```bash
382npx create-remix@latest my-app
383```
384
385--------------------------------
386
387### Install Shadcn UI Context Menu component via CLI (Bash)
388
389Source: https://ui.shadcn.com/docs/components/context-menu
390
391This 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.
392
393```bash
394npx shadcn@latest add context-menu
395```
396
397--------------------------------
398
399### Install Vaul Dependency for Manual Setup
400
401Source: https://ui.shadcn.com/docs/components/drawer
402
403Manually 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.
404
405```bash
406npm install vaul
407```
408
409--------------------------------
410
411### Install Recharts Dependency via npm
412
413Source: https://ui.shadcn.com/docs/components/chart
414
415Installs the Recharts library as a project dependency for manual setup. Required when not using the CLI installation method.
416
417```bash
418npm install recharts
419```
420
421--------------------------------
422
423### Install Shadcn UI Command Component
424
425Source: https://ui.shadcn.com/docs/components/command
426
427This 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.
428
429```bash
430npx shadcn@latest add command
431```
432
433```bash
434npm install cmdk
435```
436
437--------------------------------
438
439### Install Components from Multiple Namespaced Registries
440
441Source: https://ui.shadcn.com/docs/changelog
442
443Use 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.
444
445```bash
446npx shadcn add @acme/button @internal/auth-system
447```
448
449--------------------------------
450
451### Install Block and Override Primitives in shadcn/ui
452
453Source: https://ui.shadcn.com/docs/registry/examples
454
455Configure 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.
456
457```json
458{
459 "$schema": "https://ui.shadcn.com/schema/registry-item.json",
460 "name": "custom-login",
461 "type": "registry:block",
462 "registryDependencies": [
463 "login-01",
464 "https://example.com/r/button.json",
465 "https://example.com/r/input.json",
466 "https://example.com/r/label.json"
467 ]
468}
469```
470
471--------------------------------
472
473### Define Initial shadcn registry.json Structure
474
475Source: https://ui.shadcn.com/docs/registry/getting-started
476
477This 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.
478
479```json
480{
481 "$schema": "https://ui.shadcn.com/schema/registry.json",
482 "name": "acme",
483 "homepage": "https://acme.com",
484 "items": [
485 // ...
486 ]
487}
488```
489
490--------------------------------
491
492### List All Components from a Registry
493
494Source: https://ui.shadcn.com/docs/changelog
495
496Display all available components from a specified namespaced registry. Useful for discovering available components before installation.
497
498```bash
499npx shadcn list @acme
500```
501
502--------------------------------
503
504### Execute shadcn Registry Build Script
505
506Source: https://ui.shadcn.com/docs/registry/getting-started
507
508This 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.
509
510```bash
511npm run registry:build
512```
513
514--------------------------------
515
516### Install Shadcn UI Select Component via CLI
517
518Source: https://ui.shadcn.com/docs/components/select
519
520This 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.
521
522```bash
523npx shadcn@latest add select
524```
525
526--------------------------------
527
528### Configure shadcn Build Script in package.json
529
530Source: https://ui.shadcn.com/docs/registry/getting-started
531
532This 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.
533
534```json
535{
536 "scripts": {
537 "registry:build": "shadcn build"
538 }
539}
540```
541
542--------------------------------
543
544### Install Resources from Namespaced Registries
545
546Source: https://ui.shadcn.com/docs/components-json
547
548Install 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.
549
550```bash
551# Install from a configured registry
552npx shadcn@latest add @v0/dashboard
553
554# Install from private registry
555npx shadcn@latest add @private/button
556
557# Install multiple resources
558npx shadcn@latest add @acme/header @internal/auth-utils
559```
560
561--------------------------------
562
563### Install Kbd Component via CLI (shadcn/ui)
564
565Source: https://ui.shadcn.com/docs/components/kbd
566
567Provides 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.
568
569```bash
570npx shadcn@latest add kbd
571```
572
573--------------------------------
574
575### Handle `shadcn/ui` Initialization with React 19 Peer Dependency Prompt (npm)
576
577Source: https://ui.shadcn.com/docs/react-19
578
579This `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.
580
581```bash
582It looks like you are using React 19.
583Some packages may fail to install due to peer dependency issues (see https://ui.shadcn.com/react-19).
584
585? How would you like to proceed? › - Use arrow-keys. Return to submit.
586❯ Use --force
587 Use --legacy-peer-deps
588```
589
590--------------------------------
591
592### Install shadcn/ui Label Component via CLI
593
594Source: https://ui.shadcn.com/docs/components/label
595
596This `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.
597
598```bash
599npx shadcn@latest add label
600```
601
602--------------------------------
603
604### Add Components to Monorepo Workspace
605
606Source: https://ui.shadcn.com/docs/monorepo
607
608Add 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.
609
610```bash
611cd apps/web
612npx shadcn@latest add [COMPONENT]
613```
614
615--------------------------------
616
617### Install Shadcn UI Spinner Component via CLI (Bash)
618
619Source: https://ui.shadcn.com/docs/components/spinner
620
621Provides 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.
622
623```bash
624npx shadcn@latest add spinner
625```
626
627--------------------------------
628
629### Install Drawer Component via CLI
630
631Source: https://ui.shadcn.com/docs/components/drawer
632
633Install 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.
634
635```bash
636npx shadcn@latest add drawer
637```
638
639--------------------------------
640
641### Install Navigation Menu via CLI - shadcn/ui
642
643Source: https://ui.shadcn.com/docs/components/navigation-menu
644
645Quick 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.
646
647```bash
648npx shadcn@latest add navigation-menu
649```
650
651--------------------------------
652
653### View Registry Component Before Installation
654
655Source: https://ui.shadcn.com/docs/changelog
656
657Preview a component from a namespaced registry without installing it. Displays component code and all dependencies upfront for review.
658
659```bash
660npx shadcn view @acme/auth-system
661```
662
663--------------------------------
664
665### Install Shadcn Hover Card Component via CLI
666
667Source: https://ui.shadcn.com/docs/components/hover-card
668
669This 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.
670
671```bash
672npx shadcn@latest add hover-card
673```
674
675--------------------------------
676
677### Install Toggle Group Dependencies via npm
678
679Source: https://ui.shadcn.com/docs/components/toggle-group
680
681Install the required Radix UI toggle group dependency manually using npm. Required for projects that prefer manual component setup.
682
683```bash
684npm install @radix-ui/react-toggle-group
685```
686
687--------------------------------
688
689### Import and Use Button Component in TanStack Start
690
691Source: https://ui.shadcn.com/docs/installation/tanstack
692
693Import 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.
694
695```tsx
696import { Button } from "@/components/ui/button"
697
698function App() {
699 return (
700
701
702Click me
703
704 )
705}
706```
707
708--------------------------------
709
710### Install Carousel Component via CLI
711
712Source: https://ui.shadcn.com/docs/components/carousel
713
714shadcn/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.
715
716```bash
717npx shadcn@latest add carousel
718```
719
720--------------------------------
721
722### Install Resizable Component using Shadcn CLI
723
724Source: https://ui.shadcn.com/docs/components/resizable
725
726This 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.
727
728```bash
729npx shadcn@latest add resizable
730```
731
732--------------------------------
733
734### Install Menubar via CLI - Bash
735
736Source: https://ui.shadcn.com/docs/components/menubar
737
738Command 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.
739
740```bash
741npx shadcn@latest add menubar
742```
743
744--------------------------------
745
746### Install Radio Group via CLI - Bash
747
748Source: https://ui.shadcn.com/docs/components/radio-group
749
750Command-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.
751
752```bash
753npx shadcn@latest add radio-group
754```
755
756--------------------------------
757
758### Define reusable registry block with components
759
760Source: https://ui.shadcn.com/docs/registry/examples
761
762Create 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.
763
764```json
765{
766 "$schema": "https://ui.shadcn.com/schema/registry-item.json",
767 "name": "login-01",
768 "type": "registry:block",
769 "description": "A simple login form.",
770 "registryDependencies": ["button", "card", "input", "label"],
771 "files": [
772 {
773 "path": "blocks/login-01/page.tsx",
774 "content": "import { LoginForm } ...",
775 "type": "registry:page",
776 "target": "app/login/page.tsx"
777 },
778 {
779 "path": "blocks/login-01/components/login-form.tsx",
780 "content": "...",
781 "type": "registry:component"
782 }
783 ]
784}
785```
786
787--------------------------------
788
789### Install Radix UI Context Menu dependency manually (Bash)
790
791Source: https://ui.shadcn.com/docs/components/context-menu
792
793This 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.
794
795```bash
796npm install @radix-ui/react-context-menu
797```
798
799--------------------------------
800
801### Install Native Select component via CLI
802
803Source: https://ui.shadcn.com/docs/components/native-select
804
805Use 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.
806
807```bash
808npx shadcn@latest add native-select
809```
810
811--------------------------------
812
813### Install Empty Component via CLI
814
815Source: https://ui.shadcn.com/docs/components/empty
816
817Command to install the Empty component using the shadcn package manager. Automatically adds the component and its dependencies to the project.
818
819```bash
820npx shadcn@latest add empty
821```
822
823--------------------------------
824
825### Install shadcn Table component and TanStack React Table
826
827Source: https://ui.shadcn.com/docs/components/data-table
828
829Installation 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.
830
831```bash
832npx shadcn@latest add table
833```
834
835```bash
836npm install @tanstack/react-table
837```
838
839--------------------------------
840
841### Install Switch Component via CLI
842
843Source: https://ui.shadcn.com/docs/components/switch
844
845Command-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.
846
847```bash
848npx shadcn@latest add switch
849```
850
851--------------------------------
852
853### Start Development Server with pnpm
854
855Source: https://ui.shadcn.com/docs/blocks
856
857Starts the development server for the www application at http://localhost:3333. Enables live preview of blocks during development.
858
859```bash
860pnpm www:dev
861```
862
863--------------------------------
864
865### Install Shadcn UI Badge component via CLI (Bash)
866
867Source: https://ui.shadcn.com/docs/components/badge
868
869This 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.
870
871```bash
872npx shadcn@latest add badge
873```
874
875--------------------------------
876
877### Interactive Configuration Questions for shadcn init
878
879Source: https://ui.shadcn.com/docs/changelog
880
881Configuration 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.
882
883```text
884Which style would you like to use? › Default
885Which color would you like to use as base color? › Slate
886Where is your global CSS file? › › app/globals.css
887Do you want to use CSS variables for colors? › no / yes
888Where is your tailwind.config.js located? › tailwind.config.js
889Configure the import alias for components: › @/components
890Configure the import alias for utils: › @/lib/utils
891Are you using React Server Components? › no / yes
892```
893
894--------------------------------
895
896### Item Component Installation - Bash
897
898Source: https://ui.shadcn.com/docs/components/item
899
900CLI command to install the Item component from shadcn. Requires Node.js and npm/pnpm package manager.
901
902```bash
903npx shadcn@latest add item
904```
905
906--------------------------------
907
908### CLI Command: Initialize Project from Local File
909
910Source: https://ui.shadcn.com/docs/changelog
911
912The `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.
913
914```bash
915npx shadcn init ./template.json
916```
917
918--------------------------------
919
920### Install Tailwind CSS and Autoprefixer
921
922Source: https://ui.shadcn.com/docs/installation/remix
923
924Install Tailwind CSS and Autoprefixer as development dependencies to enable styling support for shadcn/ui components in your Remix project.
925
926```bash
927npm install -D tailwindcss@latest autoprefixer@latest
928```
929
930--------------------------------
931
932### Install Tooltip Dependencies via npm
933
934Source: https://ui.shadcn.com/docs/components/tooltip
935
936Manual 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.
937
938```bash
939npm install @radix-ui/react-tooltip
940```
941
942--------------------------------
943
944### Install Shadcn UI Dialog component using CLI or npm
945
946Source: https://ui.shadcn.com/docs/components/dialog
947
948Instructions 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.
949
950```bash
951npx shadcn@latest add dialog
952```
953
954```bash
955npm install @radix-ui/react-dialog
956```
957
958--------------------------------
959
960### Install Toggle Component via CLI
961
962Source: https://ui.shadcn.com/docs/components/toggle
963
964Install the Toggle component using the shadcn CLI tool. This command downloads and sets up the component with all dependencies in your project.
965
966```bash
967npx shadcn@latest add toggle
968```
969
970--------------------------------
971
972### Install Sheet Component via CLI
973
974Source: https://ui.shadcn.com/docs/components/sheet
975
976Command to install the Sheet component and its dependencies using the shadcn CLI. This is the recommended installation method for projects using shadcn/ui.
977
978```bash
979npx shadcn@latest add sheet
980```
981
982--------------------------------
983
984### Install Shadcn UI Popover component
985
986Source: https://ui.shadcn.com/docs/components/popover
987
988These 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.
989
990```bash
991npx shadcn@latest add popover
992```
993
994```bash
995npm install @radix-ui/react-popover
996```
997
998--------------------------------
999
1000### Install Sonner via CLI
1001
1002Source: https://ui.shadcn.com/docs/components/sonner
1003
1004Command-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.
1005
1006```bash
1007npx shadcn@latest add sonner
1008```
1009
1010--------------------------------
1011
1012### Complete Bar Chart with XAxis Implementation
1013
1014Source: https://ui.shadcn.com/docs/components/chart
1015
1016Full 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.
1017
1018```tsx
1019"use client"
1020
1021import { Bar, BarChart, CartesianGrid, XAxis } from "recharts"
1022
1023import { ChartConfig, ChartContainer } from "@/components/ui/chart"
1024
1025const chartData = [
1026 { month: "January", desktop: 186, mobile: 80 },
1027 { month: "February", desktop: 305, mobile: 200 },
1028 { month: "March", desktop: 237, mobile: 120 },
1029 { month: "April", desktop: 73, mobile: 190 },
1030 { month: "May", desktop: 209, mobile: 130 },
1031 { month: "June", desktop: 214, mobile: 140 },
1032]
1033
1034const chartConfig = {
1035 desktop: {
1036 label: "Desktop",
1037 color: "#2563eb",
1038 },
1039 mobile: {
1040 label: "Mobile",
1041 color: "#60a5fa",
1042 },
1043} satisfies ChartConfig
1044
1045export function Component() {
1046 return (
1047  value.slice(0, 3)}
1048 />
1049
1050 )
1051}
1052```
1053
1054--------------------------------
1055
1056### Environment Variables Setup
1057
1058Source: https://ui.shadcn.com/docs/registry/authentication
1059
1060Set registry authentication token in .env.local file. This stores the secret token that will be used for Bearer authentication when accessing private component registries.
1061
1062```bash
1063REGISTRY_TOKEN=your_secret_token_here
1064```
1065
1066--------------------------------
1067
1068### Install Table Component via CLI
1069
1070Source: https://ui.shadcn.com/docs/components/table
1071
1072CLI command to install the shadcn/ui Table component using npx. This automatically adds the component to your project.
1073
1074```bash
1075npx shadcn@latest add table
1076```
1077
1078--------------------------------
1079
1080### Install next-themes package
1081
1082Source: https://ui.shadcn.com/docs/dark-mode/next
1083
1084This command installs the `next-themes` package, a crucial dependency for implementing dark mode functionality in Next.js applications.
1085
1086```bash
1087npm install next-themes
1088```
1089
1090--------------------------------
1091
1092### Install Separator Component via CLI
1093
1094Source: https://ui.shadcn.com/docs/components/separator
1095
1096Install the Separator component using the shadcn CLI tool. This command automatically downloads and sets up the component in your project with all required dependencies.
1097
1098```bash
1099npx shadcn@latest add separator
1100```
1101
1102--------------------------------
1103
1104### Install Menubar Dependencies - Bash
1105
1106Source: https://ui.shadcn.com/docs/components/menubar
1107
1108Manual 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).
1109
1110```bash
1111npm install @radix-ui/react-menubar
1112```
1113
1114--------------------------------
1115
1116### Install Tooltip via shadcn CLI
1117
1118Source: https://ui.shadcn.com/docs/components/tooltip
1119
1120Command-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.
1121
1122```bash
1123npx shadcn@latest add tooltip
1124```
1125
1126--------------------------------
1127
1128### Install Slider Component via CLI
1129
1130Source: https://ui.shadcn.com/docs/components/slider
1131
1132Command-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.
1133
1134```bash
1135npx shadcn@latest add slider
1136```
1137
1138--------------------------------
1139
1140### Install Shadcn Alert component via CLI
1141
1142Source: https://ui.shadcn.com/docs/components/alert
1143
1144This 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.
1145
1146```bash
1147npx shadcn@latest add alert
1148```
1149
1150--------------------------------
1151
1152### Create a Basic shadcn Component in TSX
1153
1154Source: https://ui.shadcn.com/docs/registry/getting-started
1155
1156This 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.
1157
1158```tsx
1159import { Button } from "@/components/ui/button"
1160
1161export function HelloWorld() {
1162 return Hello World
1163}
1164```
1165
1166--------------------------------
1167
1168### Install Radix UI Switch Dependency
1169
1170Source: https://ui.shadcn.com/docs/components/switch
1171
1172NPM installation command for the Radix UI switch primitive dependency. Required when manually installing the Switch component without using the shadcn CLI tool.
1173
1174```bash
1175npm install @radix-ui/react-switch
1176```
1177
1178--------------------------------
1179
1180### Button Size Variants Example
1181
1182Source: https://ui.shadcn.com/docs/components/button
1183
1184Comprehensive example showing all Button size options: sm, icon-sm, default, icon, lg, and icon-lg. Demonstrates text and icon buttons at different sizes.
1185
1186```typescript
1187import { ArrowUpRightIcon } from "lucide-react"
1188
1189import { Button } from "@/components/ui/button"
1190
1191export function ButtonSize() {
1192 return (
1193
1194
1195Small
1196
1197
1198Default
1199
1200Large
1201
1202
1203 )
1204}
1205```
1206
1207--------------------------------
1208
1209### Create custom style extending shadcn/ui
1210
1211Source: https://ui.shadcn.com/docs/registry/examples
1212
1213Define 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`.
1214
1215```json
1216{
1217 "$schema": "https://ui.shadcn.com/schema/registry-item.json",
1218 "name": "example-style",
1219 "type": "registry:style",
1220 "dependencies": ["@tabler/icons-react"],
1221 "registryDependencies": [
1222 "login-01",
1223 "calendar",
1224 "https://example.com/r/editor.json"
1225 ],
1226 "cssVars": {
1227 "theme": {
1228 "font-sans": "Inter, sans-serif"
1229 },
1230 "light": {
1231 "brand": "20 14.3% 4.1%"
1232 },
1233 "dark": {
1234 "brand": "20 14.3% 4.1%"
1235 }
1236 }
1237}
1238```
1239
1240--------------------------------
1241
1242### Example Shadcn UI Registry Configuration (JSON)
1243
1244Source: https://ui.shadcn.com/docs/registry/registry-index
1245
1246This 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.
1247
1248```json
1249{
1250 "$schema": "https://ui.shadcn.com/schema/registry.json",
1251 "name": "acme",
1252 "homepage": "https://acme.com",
1253 "items": [
1254 {
1255 "name": "login-form",
1256 "type": "registry:component",
1257 "title": "Login Form",
1258 "description": "A login form component.",
1259 "files": [
1260 {
1261 "path": "registry/new-york/auth/login-form.tsx",
1262 "type": "registry:component"
1263 }
1264 ]
1265 },
1266 {
1267 "name": "example-login-form",
1268 "type": "registry:component",
1269 "title": "Example Login Form",
1270 "description": "An example showing how to use the login form component.",
1271 "files": [
1272 {
1273 "path": "registry/new-york/examples/example-login-form.tsx",
1274 "type": "registry:component"
1275 }
1276 ]
1277 }
1278 ]
1279}
1280```
1281
1282--------------------------------
1283
1284### Manually install Radix UI Alert Dialog dependency with npm
1285
1286Source: https://ui.shadcn.com/docs/components/alert-dialog
1287
1288This `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.
1289
1290```bash
1291npm install @radix-ui/react-alert-dialog
1292```
1293
1294--------------------------------
1295
1296### Component Diff Output Example
1297
1298Source: https://ui.shadcn.com/docs/changelog
1299
1300Example output showing differences in a component's code. The diff displays additions and removals, showing what has changed in the upstream repository.
1301
1302```diff
1303const alertVariants = cva(
1304- "relative w-full rounded-lg border",
1305+ "relative w-full pl-12 rounded-lg border"
1306)
1307```
1308
1309--------------------------------
1310
1311### Install Button Dependencies via npm
1312
1313Source: https://ui.shadcn.com/docs/components/button
1314
1315Manual installation of required dependencies for the Button component. Install the @radix-ui/react-slot package which provides slot composition functionality.
1316
1317```bash
1318npm install @radix-ui/react-slot
1319```
1320
1321--------------------------------
1322
1323### CLI Error: Missing Registry Environment Variables
1324
1325Source: https://ui.shadcn.com/docs/changelog
1326
1327This 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.
1328
1329```txt
1330Registry "@private" requires the following environment variables:
1331 • REGISTRY_TOKEN
1332
1333Set the required environment variables to your .env or .env.local file.
1334```
1335
1336--------------------------------
1337
1338### Install Multiple Resources from Different Namespaces
1339
1340Source: https://ui.shadcn.com/docs/registry/namespace
1341
1342Install multiple resources from different namespaced registries in a single command. Supports combining resources from UI components, libraries, and AI prompts across various registries.
1343
1344```bash
1345npx shadcn@latest add @acme/header @lib/auth-utils @ai/chatbot-rules
1346```
1347
1348--------------------------------
1349
1350### Define Universal Registry Item for ESLint Configuration (shadcn/ui)
1351
1352Source: https://ui.shadcn.com/docs/registry/examples
1353
1354This 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.
1355
1356```json
1357{
1358 "$schema": "https://ui.shadcn.com/schema/registry-item.json",
1359 "name": "my-eslint-config",
1360 "type": "registry:item",
1361 "files": [
1362 {
1363 "path": "/path/to/your/registry/default/custom-eslint.json",
1364 "type": "registry:file",
1365 "target": "~/.eslintrc.json",
1366 "content": "..."
1367 }
1368 ]
1369}
1370```
1371
1372--------------------------------
1373
1374### Configure Plugin with NPM Dependencies in shadcn UI
1375
1376Source: https://ui.shadcn.com/docs/registry/examples
1377
1378Shows 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.
1379
1380```json
1381{
1382 "$schema": "https://ui.shadcn.com/schema/registry-item.json",
1383 "name": "typography-component",
1384 "type": "registry:item",
1385 "dependencies": ["@tailwindcss/typography"],
1386 "css": {
1387 "@plugin "@tailwindcss/typography"": {},
1388 "@layer components": {
1389 ".prose": {
1390 "max-width": "65ch"
1391 }
1392 }
1393 }
1394}
1395```
1396
1397--------------------------------
1398
1399### Install Shadcn Accordion Component (bash)
1400
1401Source: https://ui.shadcn.com/docs/components/accordion
1402
1403This 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.
1404
1405```bash
1406npx shadcn@latest add accordion
1407```
1408
1409```bash
1410npm install @radix-ui/react-accordion
1411```
1412
1413--------------------------------
1414
1415### Install Navigation Menu Dependencies - npm
1416
1417Source: https://ui.shadcn.com/docs/components/navigation-menu
1418
1419Manual installation of required Radix UI navigation menu dependency. Use this approach when manually setting up the component instead of using the CLI.
1420
1421```bash
1422npm install @radix-ui/react-navigation-menu
1423```
1424
1425--------------------------------
1426
1427### Configure Secure Custom Registry with Authorization Headers (JSON)
1428
1429Source: https://ui.shadcn.com/docs/registry/namespace
1430
1431Provides 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.
1432
1433```json
1434{
1435 "@company": {
1436 "url": "https://registry.company.com/v1/{name}.json",
1437 "headers": {
1438 "Authorization": "Bearer ${COMPANY_TOKEN}",
1439 "X-Registry-Version": "1.0"
1440 }
1441 }
1442}
1443```
1444
1445--------------------------------
1446
1447### Create components.json Configuration File for shadcn/ui
1448
1449Source: https://ui.shadcn.com/docs/installation/manual
1450
1451This 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.
1452
1453```json
1454{
1455 "$schema": "https://ui.shadcn.com/schema.json",
1456 "style": "new-york",
1457 "rsc": false,
1458 "tsx": true,
1459 "tailwind": {
1460 "config": "",
1461 "css": "src/styles/globals.css",
1462 "baseColor": "neutral",
1463 "cssVariables": true,
1464 "prefix": ""
1465 },
1466 "aliases": {
1467 "components": "@/components",
1468 "utils": "@/lib/utils",
1469 "ui": "@/components/ui",
1470 "lib": "@/lib",
1471 "hooks": "@/hooks"
1472 },
1473 "iconLibrary": "lucide"
1474}
1475```
1476
1477--------------------------------
1478
1479### Install Button Component via CLI
1480
1481Source: https://ui.shadcn.com/docs/components/button
1482
1483Quick installation of the Button component using the shadcn CLI tool. Automatically adds the button component and its dependencies to your project.
1484
1485```bash
1486npx shadcn@latest add button
1487```
1488
1489--------------------------------
1490
1491### Install Tabs Dependencies via NPM - Bash
1492
1493Source: https://ui.shadcn.com/docs/components/tabs
1494
1495Manual npm installation of the Radix UI Tabs dependency. Use this method when manually adding the tabs component instead of using the CLI installer.
1496
1497```bash
1498npm install @radix-ui/react-tabs
1499```
1500
1501--------------------------------
1502
1503### Install Checkbox Dependencies - Bash
1504
1505Source: https://ui.shadcn.com/docs/components/checkbox
1506
1507Manual installation command for the Radix UI checkbox dependency. Required when manually setting up the checkbox component without using the CLI.
1508
1509```bash
1510npm install @radix-ui/react-checkbox
1511```
1512
1513--------------------------------
1514
1515### Add Components with add Command
1516
1517Source: https://ui.shadcn.com/docs/cli
1518
1519The add command installs specific components and their dependencies into your project. It supports single or multiple component installation, file overwriting, and path customization.
1520
1521```bash
1522npx shadcn@latest add [component]
1523```
1524
1525```bash
1526Usage: shadcn add [options] [components...]
1527
1528add a component to your project
1529
1530Arguments:
1531 components name, url or local path to component
1532
1533Options:
1534 -y, --yes skip confirmation prompt. (default: false)
1535 -o, --overwrite overwrite existing files. (default: false)
1536 -c, --cwd  the working directory. defaults to the current directory.
1537 -a, --all add all available components (default: false)
1538 -p, --path  the path to add the component to.
1539 -s, --silent mute output. (default: false)
1540 --src-dir use the src directory when creating a new project. (default: false)
1541 --no-src-dir do not use the src directory when creating a new project.
1542 --css-variables use css variables for theming. (default: true)
1543 --no-css-variables do not use css variables for theming.
1544 -h, --help display help for command
1545```
1546
1547--------------------------------
1548
1549### Create new React project with Vite
1550
1551Source: https://ui.shadcn.com/docs/installation/vite
1552
1553Initializes 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.
1554
1555```bash
1556npm create vite@latest
1557```
1558
1559--------------------------------
1560
1561### Manually Install Radix UI Label npm Dependency
1562
1563Source: https://ui.shadcn.com/docs/components/label
1564
1565For 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.
1566
1567```bash
1568npm install @radix-ui/react-label
1569```
1570
1571--------------------------------
1572
1573### Install Single Resource from Namespaced Registry
1574
1575Source: https://ui.shadcn.com/docs/registry/namespace
1576
1577Install 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.
1578
1579```bash
1580npx shadcn@latest add @v0/dashboard
1581```
1582
1583--------------------------------
1584
1585### Add UI Components with add Command
1586
1587Source: https://ui.shadcn.com/docs/changelog
1588
1589Use 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.
1590
1591```bash
1592npx shadcn@latest add
1593```
1594
1595--------------------------------
1596
1597### Install Button Group via CLI - Bash
1598
1599Source: https://ui.shadcn.com/docs/components/button-group
1600
1601Command-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.
1602
1603```bash
1604npx shadcn@latest add button-group
1605```
1606
1607--------------------------------
1608
1609### Radix UI Migration: Import Path Update Example
1610
1611Source: https://ui.shadcn.com/docs/changelog
1612
1613This `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.
1614
1615```diff
1616- import * as AlertDialogPrimitive from "@radix-ui/react-dialog"
1617+ import { AlertDialog as AlertDialogPrimitive } from "radix-ui"
1618```
1619
1620--------------------------------
1621
1622### Initialize shadcn Project with init Command
1623
1624Source: https://ui.shadcn.com/docs/cli
1625
1626The 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.
1627
1628```bash
1629npx shadcn@latest init
1630```
1631
1632```bash
1633Usage: shadcn init [options] [components...]
1634
1635initialize your project and install dependencies
1636
1637Arguments:
1638 components name, url or local path to component
1639
1640Options:
1641 -t, --template  the template to use. (next, next-monorepo)
1642 -b, --base-color  the base color to use. (neutral, gray, zinc, stone, slate)
1643 -y, --yes skip confirmation prompt. (default: true)
1644 -f, --force force overwrite of existing configuration. (default: false)
1645 -c, --cwd  the working directory. defaults to the current directory.
1646 -s, --silent mute output. (default: false)
1647 --src-dir use the src directory when creating a new project. (default: false)
1648 --no-src-dir do not use the src directory when creating a new project.
1649 --css-variables use css variables for theming. (default: true)
1650 --no-css-variables do not use css variables for theming.
1651 --no-base-style do not install the base shadcn style
1652 -h, --help display help for command
1653```
1654
1655--------------------------------
1656
1657### Install Dropdown Menu Dependencies
1658
1659Source: https://ui.shadcn.com/docs/components/dropdown-menu
1660
1661NPM installation command for the Radix UI dropdown menu primitive dependency. Required when manually adding the component without using the shadcn/ui CLI tool.
1662
1663```bash
1664npm install @radix-ui/react-dropdown-menu
1665```
1666
1667--------------------------------
1668
1669### Install Toggle Component Dependencies Manually
1670
1671Source: https://ui.shadcn.com/docs/components/toggle
1672
1673Install 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.
1674
1675```bash
1676npm install @radix-ui/react-toggle
1677```
1678
1679--------------------------------
1680
1681### Add Components with Shadcn CLI
1682
1683Source: https://ui.shadcn.com/docs/changelog
1684
1685This 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.
1686
1687```bash
1688npx shadcn add @ai-elements/prompt-input
1689```
1690
1691--------------------------------
1692
1693### Initialize MCP Server for shadcn Registries
1694
1695Source: https://ui.shadcn.com/docs/changelog
1696
1697Set 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.
1698
1699```bash
1700npx shadcn@latest mcp init
1701```
1702
1703--------------------------------
1704
1705### Install Chart Component via CLI
1706
1707Source: https://ui.shadcn.com/docs/components/chart
1708
1709Installs the chart.tsx component using shadcn's CLI tool. This command automatically sets up the chart component file in the project structure.
1710
1711```bash
1712npx shadcn@latest add chart
1713```
1714
1715--------------------------------
1716
1717### Install Card Component via CLI - shadcn
1718
1719Source: https://ui.shadcn.com/docs/components/card
1720
1721Install the Card component using the shadcn CLI tool. This command downloads and integrates the Card component into your project's components directory.
1722
1723```bash
1724npx shadcn@latest add card
1725```