--- url: /docs/about.md description: Powered by amazing open source projects. --- ## About [shadcn-vue](https://shadcn-vue.com) is a port of [shadcn/ui](https://ui.shadcn.com) for Vue/Nuxt. It's maintained by [unovue](https://github.com/unovue). ## Credits - [shadcn](https://twitter.com/shadcn) - The brilliant mind behind the designs, methodology, and implementation of the original [shadcn/ui](https://ui.shadcn.com). - [Radix Vue](https://reka-ui.com) - The headless components that power this project. - [Radix UI](https://radix-ui.com) - The headless components and examples that the original [shadcn/ui](https://ui.shadcn.com) was built on. - [Shu Ding](https://shud.in) - The typography style is adapted from his work on Nextra. - [Cal](https://cal.com) - Where shad copied the styles for the first component: the `Button`. ## License MIT © [shadcn](https://shadcn.com) & [unovue](https://github.com/unovue) --- --- url: /docs/components/accordion.md description: >- A vertically stacked set of interactive headings that each reveal a section of content. --- ## Installation ```bash npx shadcn-vue@latest add accordion ``` ## Usage ```vue ``` --- --- url: /docs/components/alert.md description: Displays a callout for user attention. --- ## Installation ```bash npx shadcn-vue@latest add alert ``` ## Usage ```vue ``` ## Examples ### Default ### Destructive --- --- url: /docs/components/alert-dialog.md description: >- A modal dialog that interrupts the user with important content and expects a response. --- ## Installation ```bash npx shadcn-vue@latest add alert-dialog ``` ## Usage ```vue ``` --- --- url: /docs/charts/area.md description: >- An area chart visually represents data over time, displaying trends and patterns through filled-in areas under a line graph. --- ## Installation Only works with Vue >3.3 ### Run the following command ```bash npx shadcn-vue@latest add chart-area ``` ### Setup Follow the [guide](/docs/charts.html#installation) to complete the setup. ## API ## Example ### Sparkline We can turn the chart into sparkline chart by hiding axis, gridline and legends. ### Custom Tooltip If you want to render custom tooltip, you can easily pass in a custom component. Refer to prop definition [here](/docs/charts.html#custom-tooltip). --- --- url: /docs/components/aspect-ratio.md description: Displays content within a desired ratio. --- ## Installation ## Usage ```vue ``` --- --- url: /docs/installation/astro.md description: Install and configure Astro. --- **Note:** The following guide is for Tailwind v4. If you are using Tailwind v3, use `shadcn-vue@1.0.3`. ### Create project Start by creating a new Astro project: ```bash npx create-astro@latest astro-app --template with-tailwindcss --install --add vue --git ``` ### Edit tsconfig.json file Add the following code to the `tsconfig.json` file to resolve paths: ```ts:line-numbers title="tsconfig.json" {4-9} { "compilerOptions": { // ... "baseUrl": ".", "paths": { "@/*": [ "./src/*" ] } // ... } } ``` ### Run the CLI Run the `shadcn` init command to setup your project: ```bash npx shadcn-vue@latest init ``` ### Add Components You can now start adding components to your project. ```bash npx shadcn-vue@latest add button ``` The command above will add the `Button` component to your project. You can then import it like this: ```astro:line-numbers {2,10} --- import { Button } from "@/components/ui/button" --- Astro ``` --- --- url: /docs/dark-mode/astro.md description: Adding dark mode to your astro app. --- ## Dark mode ### Create an inline theme script ```astro title="src/pages/index.astro" --- import '../styles/globals.css' ---

Astro

``` ### Install Dependencies ```bash npm install @vueuse/core ``` Optional, to include icons for theme button. ```bash npm install -D @iconify/vue @iconify-json/radix-icons ``` ### Add a mode toggle Place a mode toggle on your site to toggle between light and dark mode. We're using [`useColorMode`](https://vueuse.org/core/usecolormode/) from [`@vueuse/core`](https://vueuse.org/core/). > Reactive color mode (dark / light / customs) with auto data persistence. ```vue ``` ### Display the mode toggle Place a mode toggle on your site to toggle between light and dark mode. ```astro title="src/pages/index.astro" --- import '../styles/globals.css' import ModeToggle from '@/components/ModeToggle.vue'; ---

Astro

```
--- --- url: /docs/components/auto-form.md description: Automatically generate a form from Zod schema. --- **Legacy**: Component will be moved to [extended repo](https://github.com/unovue/shadcn-vue/issues/1077) with Tailwind v4 support. --- Credit: Heavily inspired by [AutoForm](https://github.com/vantezzen/auto-form) by Vantezzen ## What is AutoForm AutoForm is a drop-in form builder for your internal and low-priority forms with existing zod schemas. For example, if you already have zod schemas for your API and want to create a simple admin panel to edit user profiles, simply pass the schema to AutoForm and you're done. ## Installation ### Run the following command ```bash npx shadcn-vue@latest update form npx shadcn-vue@latest add auto-form ``` ## Field types Currently, these field types are supported out of the box: - boolean (checkbox, switch) - date (date picker) - enum (select, radio group) - number (input) - string (input, textfield) - file (file) You can add support for other field types by adding them to the `INPUT_COMPONENTS` object in `auto-form/constants.ts`. ## Zod configuration ### Validations Your form schema can use any of zod's validation methods including refine. ⚠️ However, there's a known issue with Zod’s `refine` and `superRefine` not executing whenever some object keys are missing. [Read more](https://github.com/logaretm/vee-validate/issues/4338) ### Descriptions You can use the `describe` method to set a label for each field. If no label is set, the field name will be used and un-camel-cased. ```ts const formSchema = z.object({ username: z.string().describe('Your username'), someValue: z.string(), // Will be "Some Value" }) ``` You can also configure the label with [`fieldConfig`](#label) too. ### Optional fields By default, all fields are required. You can make a field optional by using the `optional` method. ```ts const formSchema = z.object({ username: z.string().optional(), }) ``` ### Default values You can set a default value for a field using the `default` method. ```ts const formSchema = z.object({ favouriteNumber: z.number().default(5), }) ``` If you want to set default value of date, convert it to Date first using `new Date(val)`. ### Sub-objects You can nest objects to create accordion sections. ```ts const formSchema = z.object({ address: z.object({ street: z.string(), city: z.string(), zip: z.string(), // You can nest objects as deep as you want nested: z.object({ foo: z.string(), bar: z.string(), nested: z.object({ foo: z.string(), bar: z.string(), }), }), }), }) ``` Like with normal objects, you can use the `describe` method to set a label and description for the section: ```ts const formSchema = z.object({ address: z .object({ street: z.string(), city: z.string(), zip: z.string(), }) .describe('Your address'), }) ``` ### Select/Enums AutoForm supports `enum` and `nativeEnum` to create select fields. ```ts const formSchema = z.object({ color: z.enum(['red', 'green', 'blue']), }) enum BreadTypes { // For native enums, you can alternatively define a backed enum to set a custom label White = 'White bread', Brown = 'Brown bread', Wholegrain = 'Wholegrain bread', Other, } // Keep in mind that zod will validate and return the enum labels, not the enum values! const formSchema = z.object({ bread: z.nativeEnum(BreadTypes), }) ``` ### Arrays AutoForm supports arrays _of objects_. Because inferring things like field labels from arrays of strings/numbers/etc. is difficult, only objects are supported. ```ts const formSchema = z.object({ guestListName: z.string(), invitedGuests: z .array( // Define the fields for each item z.object({ name: z.string(), age: z.number(), }) ) // Optionally set a custom label - otherwise this will be inferred from the field name .describe('Guests invited to the party'), }) ``` Arrays are not supported as the root element of the form schema. You also can set default value of an array using .default(), but please make sure the array element has same structure with the schema. ```ts const formSchema = z.object({ guestListName: z.string(), invitedGuests: z .array( // Define the fields for each item z.object({ name: z.string(), age: z.number(), }) ) .describe('Guests invited to the party') .default([ { name: 'John', age: 24, }, { name: 'Jane', age: 20, }, ]), }) ``` ## Field configuration As zod doesn't allow adding other properties to the schema, you can use the `fieldConfig` prop to add additional configuration for the UI of each field. ```vue ``` ### Label You can use the `label` property to customize label if you want to overwrite the pre-defined label via [Zod's description](#descriptions). ```vue ``` ### Description You can use the `description` property to add a description below the field. ```vue ``` ### Input props You can use the `inputProps` property to pass props to the input component. You can use any props that the HTML component accepts. ```vue // This will be rendered as: ``` Disabling the label of an input can be done by using the `showLabel` property in `inputProps`. ```vue ``` ### Component By default, AutoForm will use the Zod type to determine which input component to use. You can override this by using the `component` property. ```vue ``` The complete list of supported field types is typed. Current supported types are: - `checkbox` (default for booleans) - `switch` - `date` (default for dates) - `select` (default for enums) - `radio` - `textarea` Alternatively, you can pass a Vue component to the `component` property to use a custom component. In `CustomField.vue` ```vue ``` Pass the above component in `fieldConfig`. ```vue ``` ### Named slot You can use Vue named slot to customize the rendered `AutoFormField`. ```vue ``` ### Accessing the form data There are two ways to access the form data: ### @submit The preferred way is to use the `submit` emit. This will be called when the form is submitted and the data is valid. ```vue ``` ### Controlled form By passing the `form` as props, you can control and use the method provided by `Form`. ```vue ``` ### Submitting the form You can use any `button` component to create a submit button. Most importantly is to add attributes `type="submit"`. ```vue ``` ### Adding other elements All children passed to the `AutoForm` component will be rendered below the form. ```vue ``` ### Dependencies AutoForm allows you to add dependencies between fields to control fields based on the value of other fields. For this, a `dependencies` array can be passed to the `AutoForm` component. ```vue ``` The following dependency types are supported: - `DependencyType.HIDES`: Hides the target field when the `when` function returns true - `DependencyType.DISABLES`: Disables the target field when the `when` function returns true - `DependencyType.REQUIRES`: Sets the target field to required when the `when` function returns true - `DependencyType.SETS_OPTIONS`: Sets the options of the target field to the `options` array when the `when` function returns true The `when` function is called with the value of the source field and the value of the target field and should return a boolean to indicate if the dependency should be applied. Please note that dependencies will not cause the inverse action when returning `false` - for example, if you mark a field as required in your zod schema (i.e. by not explicitly setting `optional`), returning `false` in your `REQURIES` dependency will not mark it as optional. You should instead use zod's `optional` method to mark as optional by default and use the `REQURIES` dependency to mark it as required when the dependency is met. Please note that dependencies do not have any effect on the validation of the form. You should use zod's `refine` method to validate the form based on the value of other fields. You can create multiple dependencies for the same field and dependency type - for example to hide a field based on multiple other fields. This will then hide the field when any of the dependencies are met. ## Example ### Basic ### Input Without Label This example shows how to use AutoForm input without label. ### Sub Object Automatically generate a form from a Zod schema. ### Controlled This example shows how to use AutoForm in a controlled way. ### Confirm Password Refined schema to validate that two fields match. ### API Example The form select options are fetched from an API. ### Array support You can use arrays in your schemas to create dynamic forms. ### Dependencies Create dependencies between fields. --- --- url: /docs/components/avatar.md description: An image element with a fallback for representing the user. --- ## Installation ```bash npx shadcn-vue@latest add avatar ``` ## Usage ```vue ``` --- --- url: /docs/components/badge.md description: Displays a badge or a component that looks like a badge. --- ## Installation ## Usage ```vue ``` ## Examples ### Default ### Secondary ### Outline ### Destructive --- --- url: /docs/charts/bar.md description: >- A line chart visually represents data using rectangular bars of varying lengths to compare quantities across different categories or groups. --- ## Installation Only works with Vue >3.3 ### Run the following command ```bash npx shadcn-vue@latest add chart-bar ``` ### Setup Follow the [guide](/docs/charts.html#installation) to complete the setup. ## API ## Example ### Stacked You can stack the bar chart by settings prop `type` to `stacked`. ### Rounded ### Custom Tooltip If you want to render custom tooltip, you can easily pass in a custom component. Refer to prop definition [here](/docs/charts.html#custom-tooltip). --- --- url: /block-renderer.md --- --- --- url: /docs/components/breadcrumb.md description: Displays the path to the current resource using a hierarchy of links. --- ## Installation ```bash npx shadcn-vue@latest add breadcrumb ``` ## Usage ```vue ``` ## Examples ### Custom separator Use a custom component as `slot` for `` to create a custom separator. ```vue showLineNumbers {2,20-22} ``` --- ### Dropdown You can compose `` with a `` to create a dropdown in the breadcrumb. ```vue showLineNumbers {2-7,16-26} ``` --- ### Collapsed We provide a `` component to show a collapsed state when the breadcrumb is too long. ```vue showLineNumbers {3,15} ``` --- ### Link component To use a custom link component from your routing library, you can use the `asChild` prop on ``. ```vue showLineNumbers {15-19} ``` --- ### Responsive Here's an example of a responsive breadcrumb that composes `` with ``, ``, and ``. It displays a dropdown on desktop and a drawer on mobile. --- --- url: /docs/components/button.md description: Displays a button or a component that looks like a button. --- ## Installation ## Usage ```vue ``` ## Examples ### Primary ### Secondary ### Destructive ### Outline ### Ghost ### Link ### Icon ### With Icon ### Loading ### As Child --- --- url: /docs/components/calendar.md description: A date field component that allows users to enter and edit date. --- ## About The `` component is built on top of the [RadixVue Calendar](https://www.reka-ui.com/docs/components/calendar.html) component, which uses the [@internationalized/date](https://react-spectrum.adobe.com/internationalized/date/index.html) package to handle dates. If you're looking for a range calendar, check out the [Range Calendar](/docs/components/range-calendar) component. ## Installation ```bash npx shadcn-vue@latest add calendar ``` ::: tip The component depends on the [@internationalized/date](https://react-spectrum.adobe.com/internationalized/date/index.html) package, which solves a lot of the problems that come with working with dates and times in JavaScript. Check [Dates & Times in Radix Vue](https://www.reka-ui.com/docs/guides/dates.html) for more information and installation instructions. ::: ## Datepicker You can use the `` component to build a date picker. See the [Date Picker](/docs/components/date-picker) page for more information. ## Examples ### Form ## Advanced Customization ### Month & Year Selects --- --- url: /docs/components/card.md description: 'Displays a card with header, content, and footer.' --- ## Installation ```bash npx shadcn-vue@latest add card ``` ## Usage ```vue ``` ## Examples --- --- url: /docs/components/carousel.md description: A carousel with motion and swipe built using Embla. --- ## About The carousel component is built using the [Embla Carousel](https://www.embla-carousel.com/) library. ## Installation ```bash npx shadcn-vue@latest add carousel ``` ## Usage ```vue ``` ## Examples ### Sizes To set the size of the items, you can use the `basis` utility class on the ``. Example ```vue:line-numbers title="Example" {4-6} // 33% of the carousel width. ... ... ... ``` Responsive ```vue:line-numbers title="Responsive" {4-6} // 50% on small screens and 33% on larger screens. ... ... ... ``` ### Spacing To set the spacing between the items, we use a `pl-[VALUE]` utility on the `` and a negative `-ml-[VALUE]` on the ``. **Why:** I tried to use the `gap` property or a `grid` layout on the ` CarouselContent` but it required a lot of math and mental effort to get the spacing right. I found `pl-[VALUE]` and `-ml-[VALUE]` utilities much easier to use.

You can always adjust this in your own project if you need to.
Example ```vue:line-numbers /-ml-4/ /pl-4/ ``` Responsive ```vue:line-numbers /-ml-2/ /pl-2/ /md:-ml-4/ /md:pl-4/ ``` ### Orientation Use the `orientation` prop to set the orientation of the carousel. ```vue ... ``` ### Thumbnails ## Options You can pass options to the carousel using the `opts` prop. See the [Embla Carousel docs](https://www.embla-carousel.com/api/options/) for more information. ```vue:line-numbers {3-6} ``` ## API ### Method 1 Use the `@init-api` emit method on `` component to set the instance of the API. ### Method 2 You can access it through setting a template ref on the `` component. ```vue:line-numbers {2,5,10} ``` ## Events You can listen to events using the API. To get the API instance use the `@init-api` emit method on the `` component ```vue:line-numbers {5,7-9,25} ``` See the [Embla Carousel docs](https://www.embla-carousel.com/api/events/) for more information on using events. ## Slot Props You can get the reactive slot props like `carouselRef, canScrollNext..Prev, scrollNext..Prev` using the `v-slot` directive in the `` component to extend the functionality. ```vue:line-numbers {2} ``` ## Plugins You can use the `plugins` prop to add plugins to the carousel. ```bash npm install embla-carousel-autoplay ``` ```vue:line-numbers {2,8-10} ``` See the [Embla Carousel docs](https://www.embla-carousel.com/api/plugins/) for more information on using plugins. --- --- url: /docs/changelog.md description: Latest updates and announcements. --- ## February 2025 - Reka UI & npx shadcn-vue@latest init We've updated the latest registry to support Reka UI instead of Radix Vue. The updated CLI is now available. You can now install components, themes, composables, utils and more using `npx shadcn-vue add`. This is a major step towards distributing code that you and your LLMs can access and use. With the released of [Reka UI v2](https://reka-ui.com/), `shadcn-vue@latest` command will now install Reka UI. If you want to keep using [Radix Vue](https://radix-vue.com/), please visit [here](https://radix.shadcn-vue.com/) and run `shadcn-vue@radix` command instead. 1. First up, when you init into a new app, we update your existing Tailwind files instead of overriding. 2. A component now ship its own dependencies. Take the accordion for example, it can define its Tailwind keyframes. When you add it to your project, we’ll update your tailwind.config.ts file accordingly. 3. You can also install remote components using url. `npx shadcn-vue add https://acme.com/registry/navbar.json`. 4. We have created a new schema that you can use to ship your own component registry. And since it has support for urls, you can even use it to distribute private components. 5. And a few more updates like better error handling and monorepo support. You can try the new cli today. ```bash npx shadcn-vue@latest init Sidebar01 Login01 ``` ### Update Your Project ### Update `components.json` To update an existing project to use the new CLI, update your `components.json` file to include import aliases for your **components**, **utils**, **ui**, **lib** and **composables**. ```json:line-numbers {7-13} title="components.json" inert { "$schema": "https://shadcn-vue.com/schema.json", "style": "new-york", "tailwind": { // ... }, "aliases": { "components": "@/components", "utils": "@/lib/utils", "ui": "@/components/ui", "lib": "@/lib", "composables": "@/composables" } } ``` If you're using a different import alias prefix eg `~`, replace `@` with your prefix. ### Run add components In order to perform Radix Vue to Reka UI migration easily, you can run `add` command for all your existing components. ```bash npx shadcn-vue@latest add ``` If you're using custom component, you need to migrate them [manually](https://reka-ui.com/docs/guides/migration). ## June 2024 ### New Component - Number Field A new component has been added to the project [`NumberField`](/docs/components/number-field.html). A number field allows a user to enter a number and increment or decrement the value using stepper buttons. ## May 2024 ### New Component - Charts Several kinds of chart components has been added to the project. Charts are versatile visualization tools, allowing users to represent data using various options for effective analysis. 1. [`Area Chart`](/docs/charts/area) - An area chart visually represents data over time, displaying trends and patterns through filled-in areas under a line graph. 2. [`Bar Chart`](/docs/charts/bar) - A line chart visually represents data using rectangular bars of varying lengths to compare quantities across different categories or groups. 3. [`Donut Chart`](/docs/charts/donut) - A line chart visually represents data in a circular form, similar to a pie chart but with a central void, emphasizing proportions within categories. 4. [`Line Chart`](/docs/charts/line) - A line chart visually displays data points connected by straight lines, illustrating trends or relationships over a continuous axis. ### New Component - Auto Form [`Auto Form`](/docs/components/auto-form.html) is a drop-in form builder for your internal and low-priority forms with existing zod schemas. For example, if you already have zod schemas for your API and want to create a simple admin panel to edit user profiles, simply pass the schema to AutoForm and you're done. The following form has been created by passing a `zod` schema object to our `AutoForm` component. ## April 2024 ### Component Updated - Calendar The [`Calendar`](/docs/components/calendar.html) component has been updated and is now built on top of the [RadixVue Calendar](https://www.reka-ui.com/components/calendar.html) component, which uses the [@internationalized/date](https://react-spectrum.adobe.com/internationalized/date/index.html) package to handle dates. If you're looking for a range calendar, check out the [`Range Calendar`](/docs/components/range-calendar.html) component. And if you're looking for a date picker input, check out the [`Date Picker`](/docs/components/date-picker.html) component. ### Building Blocks for the Web [`Blocks`](/blocks) are composed of different components that can be used to build your apps, with each block being a standalone section of your application. These blocks are fully responsive, accessible, and composable, and are built using the same principles as the other components in `shadcn-vue`.
## March 2024 ### New Component - Breadcrumb [`Breadcrumb`](/docs/components/breadcrumb.html) displays the path to the current resource using a hierarchy of links. ### New Component - Pin Input (OTP Input) [`Pin Input`](/docs/components/pin-input.html) allows users to input a sequence of one-character alphanumeric inputs. ### New Component - Resizable [`Resizable`](/docs/components/resizable.html) - Accessible resizable panel groups and layouts with keyboard support. ### New Component - Drawer [`Drawer`](/docs/components/drawer.html) - A drawer component for vue that is built on top of [Vaul Vue](https://github.com/unovue/vaul-vue). ## February 2024 ### New Component - Tag Inputs [`Tag inputs`](/docs/components/tags-input.html) render tags inside an input, followed by an actual text input. ## January 2024 ### New Component - Sonner [`Sonner`](/docs/components/sonner.html) is an opinionated toast component for Vue. The Sonner component is provided by [vue-sonner](https://vue-sonner.vercel.app/), which is a Vue port of Sonner, originally created by [Emil Kowalski](https://twitter.com/emilkowalski_) for React. ### New Component - Toggle Group [`Toggle Group`](/docs/components/toggle-group.html) - A set of two-state buttons that can be toggled on or off. ### New Component - Carousel [`Carousel`](/docs/components/carousel.html) - A carousel with motion and swipe built using [Embla](https://www.embla-carousel.com/) library. --- --- url: /docs/charts.md description: >- Versatile visualization tool, allowing users to represent data using various types of charts for effective analysis. --- **Legacy**: Component will be moved to [extended repo](https://github.com/unovue/shadcn-vue/issues/1077) with Tailwind v4 support. --- Only works with Vue >3.3 `Charts` components were built on top of [Unovis](https://unovis.dev/) (a modular data visualization framework), and inspired by [tremor](https://www.tremor.so). ## Chart type

Area

Line

Bar

Donut

## Installation ### Update `css` Add the following tooltip styling to your `tailwind.css` file: ```css @layer base { :root { /* ... */ --vis-tooltip-background-color: none !important; --vis-tooltip-border-color: none !important; --vis-tooltip-text-color: none !important; --vis-tooltip-shadow-color: none !important; --vis-tooltip-backdrop-filter: none !important; --vis-tooltip-padding: none !important; --vis-primary-color: var(--primary); /* change to any hsl value you want */ --vis-secondary-color: 160 81% 40%; --vis-text-color: var(--muted-foreground); } } ``` If you are not using `css-variables` for your component, you need to update the `--vis-primary-color` and `--vis-text-color` to your desired hsl value. You may use [this tool](https://redpixelthemes.com/blog/tailwindcss-colors-different-formats/) to help you find the hsl value for your primary color and text color. Be sure to provide `dark` mode styling as well. ## Colors By default, we construct the primary theme color, and secondary (`--vis-secondary-color`) color with different opacity for the graph. However, you can always pass in the desired `color` into each chart. ```vue ``` ## Custom tooltip If you want to customize the `Tooltip` for the chart, you can pass `customTooltip` prop with a custom Vue component. The custom component would receive `title` and `data` props, check out [ChartTooltip.vue component](https://github.com/unovue/shadcn-vue/tree/dev/apps/www/registry/default/ui/chart/ChartTooltip.vue) for example. The expected prop definition would be: ```ts defineProps<{ title?: string data: { name: string color: string value: any }[] }>() ``` --- --- url: /docs/components/checkbox.md description: A control that allows the user to toggle between checked and not checked. --- ## Installation ```bash npx shadcn-vue@latest add checkbox ``` ## Usage ```vue ``` ## Examples ### With text ### Disabled ### Form Please first read `vee-validate` section for [Checkbox and Radio Inputs](https://vee-validate.logaretm.com/v4/examples/checkboxes-and-radio/) --- --- url: /docs/cli.md description: Use the CLI to add components to your project. --- ## init Use the `init` command to initialize configuration and dependencies for a new project. The `init` command installs dependencies, adds the `cn` util, configures `tailwind.config.js`, and CSS variables for the project. ```bash npx shadcn-vue@latest init ``` You will be asked a few questions to configure `components.json`: ```:line-numbers Which style would you like to use? › New York Which color would you like to use as base color? › Zinc Do you want to use CSS variables for colors? › no / yes ``` ### Options ```txt Usage: shadcn-vue init [options] [components...] initialize your project and install dependencies Arguments: components the components to add or a url to the component. Options: -d, --defaults use default values i.e new-york, zinc and css variables. (default: false) -f, --force force overwrite of existing components.json. (default: false) -y, --yes skip confirmation prompt. (default: false) -c, --cwd the working directory. defaults to the current directory. -h, --help display help for command ``` ## add Use the `add` command to add components and dependencies to your project. ```bash npx shadcn-vue@latest add [component] ``` You will be presented with a list of components to choose from: ```txt Which components would you like to add? › Space to select. A to toggle all. Enter to submit. ◯ accordion ◯ alert ◯ alert-dialog ◯ aspect-ratio ◯ avatar ◯ badge ◯ button ◯ calendar ◯ card ◯ checkbox ``` ### Options ```txt Usage: shadcn-vue add [options] [components...] add a component to your project Arguments: components the components to add or a url to the component. Options: -y, --yes skip confirmation prompt. (default: false) -o, --overwrite overwrite existing files. (default: false) -c, --cwd the working directory. defaults to the current directory. -a, --all add all available components. (default: false) -p, --path the path to add the component to. -h, --help display help for command ``` ## Monorepo In a monorepo, you can specify the path to your workspace with the `-c` or `--cwd` option. ```bash npx shadcn-vue@latest init -c ./apps/www ``` or ```bash npx shadcn-vue@latest add alert-dialog -c ./apps/www ``` --- --- url: /docs/components/collapsible.md description: An interactive component which expands/collapses a panel. --- ## Installation ```bash npx shadcn-vue@latest add collapsible ``` ## Usage ```vue ``` --- --- url: /docs/components/combobox.md description: Autocomplete input and command palette with a list of suggestions. ---
## Installation ```bash npx shadcn-vue@latest add combobox ``` ## Usage ```vue ``` ## Examples ### Combobox Trigger ### Form --- --- url: /docs/components/command.md description: 'Fast, composable, unstyled command menu.' --- ## Installation ```bash npx shadcn-vue@latest add command ``` ## Usage ```vue ``` ## Examples ### Dialog To show the command menu in a dialog, use the `` component. ```vue ```

You can use the `` component like a combobox. ### Popover ### Dropdown menu ### Responsive You can create a responsive combobox by using the `` on desktop and the `` components on mobile. ### Form --- --- url: /docs/components-json.md description: Configuration for your project. --- The `components.json` file holds configuration for your project. We use it to understand how your project is set up and how to generate components customized for your project. Note: The `components.json` file is optional and **only required if you're using the CLI** to add components to your project. If you're using the copy and paste method, you don't need this file. You can create a `components.json` file in your project by running the following command: ```bash npx shadcn-vue@latest init ``` See the [CLI section](/docs/cli) for more information. ## $schema You can see the JSON Schema for `components.json` [here](https://shadcn-vue.com/schema.json). ```json title="components.json" { "$schema": "https://shadcn-vue.com/schema.json" } ``` ## style The style for your components. **This cannot be changed after initialization.** ```json title="components.json" { "style": "default" | "new-york" } ``` ## Tailwind Configuration to help the CLI understand how Tailwind CSS is set up in your project. See the [installation section](/docs/installation) for how to set up Tailwind CSS. ### tailwind.config Path to where your `tailwind.config.js` file is located. ```json title="components.json" { "tailwind": { "config": "tailwind.config.js" | "tailwind.config.ts" } } ``` ### tailwind.css Path to the CSS file that imports Tailwind CSS into your project. ```json title="components.json" { "tailwind": { "css": "src/assets/index.css" } } ``` ### tailwind.baseColor This is used to generate the default color palette for your components. **This cannot be changed after initialization.** ```json title="components.json" { "tailwind": { "baseColor": "gray" | "neutral" | "slate" | "stone" | "zinc" } } ``` ### tailwind.cssVariables You can choose between using CSS variables or Tailwind CSS utility classes for theming. To use utility classes for theming set `tailwind.cssVariables` to `false`. For CSS variables, set `tailwind.cssVariables` to `true`. ```json title="components.json" { "tailwind": { "cssVariables": `true` | `false` } } ``` For more information, see the [theming docs](/docs/theming). **This cannot be changed after initialization.** To switch between CSS variables and utility classes, you'll have to delete and re-install your components. ### tailwind.prefix The prefix to use for your Tailwind CSS utility classes. Components will be added with this prefix. ```json title="components.json" { "tailwind": { "prefix": "tw-" } } ``` ## aliases The CLI uses these values and the `paths` config from your `tsconfig.json` or `jsconfig.json` file to place generated components in the correct location. Path aliases have to be set up in your `tsconfig.json` or `jsconfig.json` file. > A fallback to `tsconfig.app.json` if no `paths` were found in `tsconfig.json` **Important:** If you're using the `src` directory, make sure it is included under `paths` in your `tsconfig.json` or `jsconfig.json` file. ### aliases.utils Import alias for your utility functions. ```json title="components.json" { "aliases": { "utils": "@/lib/utils" } } ``` ### aliases.components Import alias for your components. ```json title="components.json" { "aliases": { "components": "@/components" } } ``` ### aliases.ui Import alias for `ui` components. The CLI will use the `aliases.ui` value to determine where to place your `ui` components. Use this config if you want to customize the installation directory for your `ui` components. ```json title="components.json" { "aliases": { "ui": "@/app/ui" } } ``` ### aliases.lib Import alias for `lib` functions such as `cn` or `valueUpdater`. ```json title="components.json" { "aliases": { "lib": "@/lib" } } ``` ### aliases.composables Import alias for `composables` such as `useMediaQuery` or `useToast`. ```json title="components.json" { "aliases": { "composables": "@/composables" } } ``` --- --- url: /docs/components/context-menu.md description: >- Displays a menu to the user — such as a set of actions or functions — triggered by a button. --- ## Installation ```bash npx shadcn-vue@latest add context-menu ``` ## Usage ```vue ``` --- --- url: /docs/dark-mode.md description: Adding dark mode to your site. ---

Vite

Nuxt

Vitepress

Astro

--- --- url: /docs/components/data-table.md description: Powerful table and datagrids built using TanStack Table. --- ## Introduction Every data table or datagrid I've created has been unique. They all behave differently, have specific sorting and filtering requirements, and work with different data sources. It doesn't make sense to combine all of these variations into a single component. If we do that, we'll lose the flexibility that [headless UI](https://tanstack.com/table/latest/docs/introduction#what-is-headless-ui) provides. So instead of a data-table component, I thought it would be more helpful to provide a guide on how to build your own. We'll start with the basic `` component and build a complex data table from scratch. **Tip:** If you find yourself using the same table in multiple places in your app, you can always extract it into a reusable component. ## Table of Contents This guide will show you how to use [TanStack Table](https://tanstack.com/table/v8) and the `
` component to build your own custom data table. We'll cover the following topics: - [Basic Table](#basic-table) - [Row Actions](#row-actions) - [Pagination](#pagination) - [Sorting](#sorting) - [Filtering](#filtering) - [Visibility](#visibility) - [Row Selection](#row-selection) - [Reusable Components](#reusable-components) ## Installation 1. Add the `
` component to your project: ```bash npx shadcn-vue@latest add table ``` 2. Add `tanstack/vue-table` dependency: ```bash npm install @tanstack/vue-table ``` ## Examples ### Column Pinning ### Reactive Table A reactive table was added in `v8.20.0` of the TanStack Table. You can see the [docs](https://tanstack.com/table/latest/docs/framework/vue/guide/table-state#using-reactive-data) for more information. We added an example where we are randomizing `status` column. One main point is that you need to mutate **full** data, as it is a `shallowRef` object. > __*⚠️ `shallowRef` is used under the hood for performance reasons, meaning that the data is not deeply reactive, only the `.value` is. To update the data you have to mutate the data directly.*__ Relative PR: [Tanstack/table #5687](https://github.com/TanStack/table/pull/5687#issuecomment-2281067245) If you want to mutate `props.data`, you should use [`defineModel`](https://vuejs.org/api/sfc-script-setup.html#definemodel). There is no difference between using `ref` or `shallowRef` for your data object; it will be automatically mutated by the TanStack Table to `shallowRef`. ## Prerequisites We are going to build a table to show recent payments. Here's what our data looks like: ```ts:line-numbers interface Payment { id: string amount: number status: 'pending' | 'processing' | 'success' | 'failed' email: string } export const payments: Payment[] = [ { id: '728ed52f', amount: 100, status: 'pending', email: 'm@example.com', }, { id: '489e1d42', amount: 125, status: 'processing', email: 'example@gmail.com', }, // ... ] ``` ## Project Structure Start by creating the following file structure: ```ansi components └── payments ├── columns.ts ├── data-table.vue ├── data-table-dropdown.vue └── app.vue ``` I'm using a Nuxt example here but this works for any other Vue framework. - `columns.ts` It will contain our column definitions. - `data-table.vue` It will contain our `` component. - `data-table-dropdown.vue` It will contain our `` component. - `app.vue` This is where we'll fetch data and render our table. ## Basic Table Let's start by building a basic table. ### Column Definitions First, we'll define our columns in the `columns.ts` file. ```ts:line-numbers import { h } from 'vue' export const columns: ColumnDef[] = [ { accessorKey: 'amount', header: () => h('div', { class: 'text-right' }, 'Amount'), cell: ({ row }) => { const amount = Number.parseFloat(row.getValue('amount')) const formatted = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', }).format(amount) return h('div', { class: 'text-right font-medium' }, formatted) }, } ] ``` **Note:** Columns are where you define the core of what your table will look like. They define the data that will be displayed, how it will be formatted, sorted and filtered. ### `` component Next, we'll create a `` component to render our table. ```vue ``` **Tip**: If you find yourself using `` in multiple places, this is the component you could make reusable by extracting it to `components/ui/data-table.vue`. `` ### Render the table Finally, we'll render our table in our index component. ```vue ``` ## Cell Formatting Let's format the amount cell to display the dollar amount. We'll also align the cell to the right. ### Update columns definition Update the `header` and `cell` definitions for amount as follows: ```ts import { h } from 'vue' export const columns: ColumnDef[] = [ { accessorKey: 'amount', header: () => h('div', { class: 'text-right' }, 'Amount'), cell: ({ row }) => { const amount = Number.parseFloat(row.getValue('amount')) const formatted = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', }).format(amount) return h('div', { class: 'text-right font-medium' }, formatted) }, } ] ``` You can use the same approach to format other cells and headers. ## Row Actions Let's add row actions to our table. We'll use a `` component for this. ### Add the following into your `DataTableDropDown.vue` component ```vue ``` ### Update columns definition Update our columns definition to add a new `actions` column. The `actions` cell returns a `` component. ```ts import DropdownAction from '@/components/DataTableDropDown.vue' import { ColumnDef } from '@tanstack/vue-table' export const columns: ColumnDef[] = [ // ... { id: 'actions', enableHiding: false, cell: ({ row }) => { const payment = row.original return h('div', { class: 'relative' }, h(DropdownAction, { payment, })) }, }, ] ``` You can access the row data using `row.original` in the `cell` function. Use this to handle actions for your row eg. use the `id` to make a DELETE call to your API. ## Pagination Next, we'll add pagination to our table. ### Update `` ```ts:line-numbers {4,12} import { FlexRender, getCoreRowModel, getPaginationRowModel, useVueTable, } from "@tanstack/vue-table" const table = useVueTable({ get data() { return props.data }, get columns() { return props.columns }, getCoreRowModel: getCoreRowModel(), getPaginationRowModel: getPaginationRowModel(), }) ``` This will automatically paginate your rows into pages of 10. See the [pagination docs](https://tanstack.com/table/v8/docs/api/features/pagination) for more information on customizing page size and implementing manual pagination. ### Add pagination controls We can add pagination controls to our table using the ` ``` --- --- url: /docs/charts/donut.md description: >- A line chart visually represents data in a circular form, similar to a pie chart but with a central void, emphasizing proportions within categories. --- ## Installation Only works with Vue >3.3 ### Run the following command ```bash npx shadcn-vue@latest add chart-donut ``` ### Setup Follow the [guide](/docs/charts.html#installation) to complete the setup. ## API ## Example ### Pie Chart If you want to render pie chart instead, pass `type` as `pie`. ### Color We generate colors automatically based on the primary and secondary color and assigned them accordingly. Feel free to pass in your own array of colors. ### Custom Tooltip If you want to render custom tooltip, you can easily pass in a custom component. Refer to prop definition [here](/docs/charts.html#custom-tooltip). --- --- url: /docs/components/drawer.md description: A drawer component for vue. --- ## About Drawer is built on top of [Vaul Vue](https://github.com/unovue/vaul-vue). ## Installation ```bash npx shadcn-vue@latest add drawer ``` ## Usage ```vue showLineNumbers ``` ### Scale Background If you want the background to have a zoom effect, you need to add the `vaul-drawer-wrapper` attribute to the root component. ```html
``` ## Examples ### Responsive Dialog You can combine the `Dialog` and `Drawer` components to create a responsive dialog. This renders a `Dialog` component on desktop and a `Drawer` on mobile. --- --- url: /docs/components/dropdown-menu.md description: >- Displays a menu to the user — such as a set of actions or functions — triggered by a button. --- ## Installation ```bash npx shadcn-vue@latest add dropdown-menu ``` ## Usage ```vue ``` ## Examples ### Checkboxes ### Radio Group --- --- url: /docs/registry/examples.md description: 'Examples of registry items: styles, components, css vars, etc.' --- ## registry:style ### Custom style that extends shadcn-vue The following registry item is a custom style that extends shadcn-vue. On `npx shadcn-vue init`, it will: - Install `@iconify/vue` as a dependency. - Add the `Login01` block and `calendar` component to the project. - Add the `editor` from a remote registry. - Set the `font-sans` variable to `Inter, sans-serif`. - Install a `brand` color in light and dark mode. ```json:line-numbers title="example-style.json" { "$schema": "https://shadcn-vue.com/schema/registry-item.json", "name": "example-style", "type": "registry:style", "dependencies": ["@iconify/vue"], "registryDependencies": [ "Login01", "calendar", "https://example.com/r/editor.json" ], "cssVars": { "theme": { "font-sans": "Inter, sans-serif" }, "light": { "brand": "20 14.3% 4.1%" }, "dark": { "brand": "20 14.3% 4.1%" } } } ``` ### Custom style from scratch The following registry item is a custom style that doesn't extend shadcn-vue. See the `extends: none` field. It can be used to create a new style from scratch i.e custom components, css vars, dependencies, etc. On `npx shadcn-vue add`, the following will: - Install `tailwind-merge` and `clsx` as dependencies. - Add the `utils` registry item from the shadcn-vue registry. - Add the `button`, `input`, `label`, and `select` components from a remote registry. - Install new css vars: `main`, `bg`, `border`, `text`, `ring`. ```json:line-numbers title="example-style.json" { "$schema": "https://shadcn-vue.com/schema/registry-item.json", "extends": "none", "name": "new-style", "type": "registry:style", "dependencies": ["tailwind-merge", "clsx"], "registryDependencies": [ "utils", "https://example.com/r/button.json", "https://example.com/r/input.json", "https://example.com/r/label.json", "https://example.com/r/select.json" ], "cssVars": { "theme": { "font-sans": "Inter, sans-serif", } "light": { "main": "#88aaee", "bg": "#dfe5f2", "border": "#000", "text": "#000", "ring": "#000", }, "dark": { "main": "#88aaee", "bg": "#272933", "border": "#000", "text": "#e6e6e6", "ring": "#fff", } } } ``` ## registry:theme ### Custom theme ```json:line-numbers title="example-theme.json" { "$schema": "https://shadcn-vue.com/schema/registry-item.json", "name": "custom-theme", "type": "registry:theme", "cssVars": { "light": { "background": "oklch(1 0 0)", "foreground": "oklch(0.141 0.005 285.823)", "primary": "oklch(0.546 0.245 262.881)", "primary-foreground": "oklch(0.97 0.014 254.604)", "ring": "oklch(0.746 0.16 232.661)", "sidebar-primary": "oklch(0.546 0.245 262.881)", "sidebar-primary-foreground": "oklch(0.97 0.014 254.604)", "sidebar-ring": "oklch(0.746 0.16 232.661)" }, "dark": { "background": "oklch(1 0 0)", "foreground": "oklch(0.141 0.005 285.823)", "primary": "oklch(0.707 0.165 254.624)", "primary-foreground": "oklch(0.97 0.014 254.604)", "ring": "oklch(0.707 0.165 254.624)", "sidebar-primary": "oklch(0.707 0.165 254.624)", "sidebar-primary-foreground": "oklch(0.97 0.014 254.604)", "sidebar-ring": "oklch(0.707 0.165 254.624)" } } } ``` ### Custom colors The following style will init using shadcn-vue defaults and then add a custom `brand` color. ```json:line-numbers title="example-style.json" { "$schema": "https://shadcn-vue.com/schema/registry-item.json", "name": "custom-style", "type": "registry:style", "cssVars": { "light": { "brand": "oklch(0.99 0.00 0)" }, "dark": { "brand": "oklch(0.14 0.00 286)" } } } ``` ## registry:block ### Custom block This blocks installs the `Login01` block from the shadcn-vue registry. ```json:line-numbers title="Login01.json" { "$schema": "https://shadcn-vue.com/schema/registry-item.json", "name": "Login01", "type": "registry:block", "description": "A simple login form.", "registryDependencies": ["button", "card", "input", "label"], "files": [ { "path": "blocks/Login01/page.vue", "content": "import { LoginForm } ...", "type": "registry:page", "target": "pages/login/index.vue" }, { "path": "blocks/Login01/components/LoginForm.vue", "content": "...", "type": "registry:component" } ] } ``` ### Install a block and override primitives You can install a block fromt the shadcn-vue registry and override the primitives using your custom ones. On `npx shadcn-vue add`, the following will: - Add the `Login01` block from the shadcn-vue registry. - Override the `button`, `input`, and `label` primitives with the ones from the remote registry. ```json:line-numbers title="example-style.json" { "$schema": "https://shadcn-vue.com/schema/registry-item.json", "name": "custom-login", "type": "registry:block", "registryDependencies": [ "Login01", "https://example.com/r/button.json", "https://example.com/r/input.json", "https://example.com/r/label.json" ] } ``` ## CSS Variables ### Custom Theme Variables Add custom theme variables to the `theme` object. ```json:line-numbers title="example-theme.json" { "$schema": "https://shadcn-vue.com/schema/registry-item.json", "name": "custom-theme", "type": "registry:theme", "cssVars": { "theme": { "font-heading": "Inter, sans-serif", "shadow-card": "0 0 0 1px rgba(0, 0, 0, 0.1)" } } } ``` ### Override Tailwind CSS variables ```json:line-numbers title="example-theme.json" { "$schema": "https://shadcn-vue.com/schema/registry-item.json", "name": "custom-theme", "type": "registry:theme", "cssVars": { "theme": { "spacing": "0.2rem", "breakpoint-sm": "640px", "breakpoint-md": "768px", "breakpoint-lg": "1024px", "breakpoint-xl": "1280px", "breakpoint-2xl": "1536px" } } } ``` ## Add custom CSS ### Base styles ```json:line-numbers title="example-base.json" { "$schema": "https://shadcn-vue.com/schema/registry-item.json", "name": "custom-style", "type": "registry:style", "css": { "@layer base": { "h1": { "font-size": "var(--text-2xl)" }, "h2": { "font-size": "var(--text-xl)" } } } } ``` ### Components ```json:line-numbers title="example-card.json" { "$schema": "https://shadcn-vue.com/schema/registry-item.json", "name": "custom-card", "type": "registry:component", "css": { "@layer components": { "card": { "background-color": "var(--color-white)", "border-radius": "var(--rounded-lg)", "padding": "var(--spacing-6)", "box-shadow": "var(--shadow-xl)" } } } } ``` ## Add custom utilities ### Simple utility ```json:line-numbers title="example-component.json" { "$schema": "https://shadcn-vue.com/schema/registry-item.json", "name": "custom-component", "type": "registry:component", "css": { "@utility content-auto": { "content-visibility": "auto" } } } ``` ### Complex utility ```json:line-numbers title="example-utility.json" { "$schema": "https://shadcn-vue.com/schema/registry-item.json", "name": "custom-component", "type": "registry:component", "css": { "@utility scrollbar-hidden": { "scrollbar-hidden": { "&::-webkit-scrollbar": { "display": "none" } } } } } ``` ### Functional utilities ```json:line-numbers title="example-functional.json" { "$schema": "https://shadcn-vue.com/schema/registry-item.json", "name": "custom-component", "type": "registry:component", "css": { "@utility tab-*": { "tab-size": "var(--tab-size-*)" } } } ``` ## Add custom animations Note: you need to define both `@keyframes` in css and `theme` in cssVars to use animations. ```json:line-numbers title="example-component.json" { "$schema": "https://shadcn-vue.com/schema/registry-item.json", "name": "custom-component", "type": "registry:component", "cssVars": { "theme": { "--animate-wiggle": "wiggle 1s ease-in-out infinite" } }, "css": { "@keyframes wiggle": { "0%, 100%": { "transform": "rotate(-3deg)" }, "50%": { "transform": "rotate(3deg)" } } } } ``` --- --- url: /docs/registry/faq.md description: Frequently asked questions about running a registry. --- ## Frequently asked questions ### What does a complex component look like? Here's an example of a complex component that installs a page, two components, a composable, a format date utils and a config file. ```json:line-numbers { "$schema": "https://shadcn-vue.com/schema/registry-item.json", "name": "hello-world", "title": "Hello World", "type": "registry:block", "description": "A complex hello world component", "files": [ { "path": "registry/new-york/HelloWorld/page.vue", "type": "registry:page", "target": "pages/hello/index.vue" }, { "path": "registry/new-york/HelloWorld/components/HelloWorld.vue", "type": "registry:component" }, { "path": "registry/new-york/HelloWorld/components/FormattedMessage.vue", "type": "registry:component" }, { "path": "registry/new-york/HelloWorld/composables/useHello.ts", "type": "registry:hook" }, { "path": "registry/new-york/HelloWorld/lib/formatDate.ts", "type": "registry:utils" }, { "path": "registry/new-york/HelloWorld/hello.config.ts", "type": "registry:file", "target": "~/hello.config.ts" } ] } ``` ### How do I add a new Tailwind color? To add a new color you need to add it to `cssVars` and `tailwind.config.theme.extend.colors`. ```json:line-numbers {10-19} {24-29} { "$schema": "https://shadcn-vue.com/schema/registry-item.json", "name": "hello-world", "title": "Hello World", "type": "registry:block", "description": "A complex hello world component", "files": [ // ... ], "cssVars": { "light": { "brand-background": "20 14.3% 4.1%", "brand-accent": "20 14.3% 4.1%" }, "dark": { "brand-background": "20 14.3% 4.1%", "brand-accent": "20 14.3% 4.1%" } }, "tailwind": { "config": { "theme": { "extend": { "colors": { "brand": { "DEFAULT": "hsl(var(--brand-background))", "accent": "hsl(var(--brand-accent))" } } } } } } } ``` The CLI will update the project CSS file and tailwind.config.js file. Once updated, the new colors will be available to be used as utility classes: `bg-brand` and `text-brand-accent`. ### How do I add a Tailwind animation? To add a new animation you add it to `tailwind.config.theme.extend.animation` and `tailwind.config.theme.extend.keyframes`. ```json:line-numbers {14-22} { "$schema": "https://shadcn-vue.com/schema/registry-item.json", "name": "hello-world", "title": "Hello World", "type": "registry:block", "description": "A complex hello world component", "files": [ // ... ], "tailwind": { "config": { "theme": { "extend": { "keyframes": { "wiggle": { "0%, 100%": { "transform": "rotate(-3deg)" }, "50%": { "transform": "rotate(3deg)" } } }, "animation": { "wiggle": "wiggle 1s ease-in-out infinite" } } } } } } ``` --- --- url: /docs/figma.md description: >- Every component recreated in Figma. With customizable props, typography and icons. --- The Figma UI Kit is open sourced by [Pietro Schirano](https://twitter.com/skirano).