# Nuxt Ui > A stacked set of collapsible panels. --- # Source: https://ui.nuxt.com/raw/docs/components/accordion.md # Accordion > A stacked set of collapsible panels. ## Usage Use the Accordion component to display a list of collapsible items. ```vue ``` ### Items Use the `items` prop as an array of objects with the following properties: - `label?: string` - `icon?: string` - `trailingIcon?: string` - `content?: string` - `value?: string` - `disabled?: boolean` - [`slot?: string`](#with-custom-slot) - `class?: any` - `ui?: { item?: ClassNameValue, header?: ClassNameValue, trigger?: ClassNameValue, leadingIcon?: ClassNameValue, label?: ClassNameValue, trailingIcon?: ClassNameValue, content?: ClassNameValue, body?: ClassNameValue }` ```vue ``` ### Multiple Set the `type` prop to `multiple` to allow multiple items to be active at the same time. Defaults to `single`. ```vue ``` ### Collapsible When `type` is `single`, you can set the `collapsible` prop to `false` to prevent the active item from collapsing. ```vue ``` ### Unmount Use the `unmount-on-hide` prop to prevent the content from being unmounted when the accordion is collapsed. Defaults to `true`. ```vue ``` > [!NOTE] > You can inspect the DOM to see each item's content being rendered. ### Disabled Use the `disabled` property to disable the Accordion. You can also disable a specific item by using the `disabled` property in the item object. ```vue ``` ### Trailing Icon Use the `trailing-icon` prop to customize the trailing [Icon](/docs/components/icon) of each item. Defaults to `i-lucide-chevron-down`. > [!TIP] > You can also set an icon for a specific item by using the `trailingIcon` property in the item object. ```vue ``` **Nuxt:** > [!TIP] > See: /docs/getting-started/integrations/icons/nuxt#theme > You can customize this icon globally in your `app.config.ts` under `ui.icons.chevronDown` key. **Vue:** > [!TIP] > See: /docs/getting-started/integrations/icons/vue#theme > You can customize this icon globally in your `vite.config.ts` under `ui.icons.chevronDown` key. ## Examples ### Control active item(s) You can control the active item by using the `default-value` prop or the `v-model` directive with the `value` of the item. If no `value` is provided, it defaults to the index **as a string**. ```vue [AccordionModelValueExample.vue] ``` > [!TIP] > Use the `value-key` prop to change the key used to match items when a `v-model` or `default-value` is provided. > [!CAUTION] > When `type="multiple"`, ensure to pass an array to the `default-value` prop or the `v-model` directive. ### With drag and drop Use the [`useSortable`](https://vueuse.org/integrations/useSortable/) composable from [`@vueuse/integrations`](https://vueuse.org/integrations/README.html) to enable drag and drop functionality on the Accordion. This integration wraps [Sortable.js](https://sortablejs.github.io/Sortable/) to provide a seamless drag and drop experience. ```vue [AccordionDragAndDropExample.vue] ``` ### With body slot Use the `#body` slot to customize the body of each item. ```vue [AccordionBodySlotExample.vue] ``` > [!TIP] > The `#body` slot includes some pre-defined styles, use the [`#content` slot](#with-content-slot) if you want to start from scratch. ### With content slot Use the `#content` slot to customize the content of each item. ```vue [AccordionContentSlotExample.vue] ``` ### With custom slot Use the `slot` property to customize a specific item. You will have access to the following slots: - `#{{ item.slot }}` - `#{{ item.slot }}-body` ```vue [AccordionCustomSlotExample.vue] ``` ### With markdown content You can use the [MDC](https://github.com/nuxt-modules/mdc?tab=readme-ov-file#mdc) component from `@nuxtjs/mdc` to render markdown in the accordion items. ```vue [AccordionMarkdownExample.vue] ``` ## API ### Props ```ts /** * Props for the Accordion component */ interface AccordionProps { /** * The element or component this component should render as. */ as?: any; items?: T[] | undefined; /** * The icon displayed on the right side of the trigger. */ trailingIcon?: any; /** * The key used to get the value from the item. * @default "\"value\"" */ valueKey?: GetItemKeys | undefined; /** * The key used to get the label from the item. * @default "\"label\"" */ labelKey?: GetItemKeys | undefined; ui?: { root?: ClassNameValue; item?: ClassNameValue; header?: ClassNameValue; trigger?: ClassNameValue; content?: ClassNameValue; body?: ClassNameValue; leadingIcon?: ClassNameValue; trailingIcon?: ClassNameValue; label?: ClassNameValue; } | undefined; /** * When type is "single", allows closing content when clicking trigger for an open item. * When type is "multiple", this prop has no effect. * @default "true" */ collapsible?: boolean | undefined; /** * The default active value of the item(s). * * Use when you do not need to control the state of the item(s). */ defaultValue?: string | string[] | undefined; /** * The controlled value of the active item(s). * * Use this when you need to control the state of the items. Can be binded with `v-model` */ modelValue?: string | string[] | undefined; /** * Determines whether a "single" or "multiple" items can be selected at a time. * * This prop will overwrite the inferred type from `modelValue` and `defaultValue`. * @default "\"single\"" */ type?: SingleOrMultipleType | undefined; /** * When `true`, prevents the user from interacting with the accordion and all its items */ disabled?: boolean | undefined; /** * When `true`, the element will be unmounted on closed state. * @default "true" */ unmountOnHide?: boolean | undefined; } ``` ### Slots ```ts /** * Slots for the Accordion component */ interface AccordionSlots { leading(): any; default(): any; trailing(): any; content(): any; body(): any; } ``` ### Emits ```ts /** * Emitted events for the Accordion component */ interface AccordionEmits { update:modelValue: (payload: [value: string | string[] | undefined]) => void; } ``` ## Theme ```ts [app.config.ts] export default defineAppConfig({ ui: { accordion: { slots: { root: 'w-full', item: 'border-b border-default last:border-b-0', header: 'flex', trigger: 'group flex-1 flex items-center gap-1.5 font-medium text-sm py-3.5 focus-visible:outline-primary min-w-0', content: 'data-[state=open]:animate-[accordion-down_200ms_ease-out] data-[state=closed]:animate-[accordion-up_200ms_ease-out] overflow-hidden focus:outline-none', body: 'text-sm pb-3.5', leadingIcon: 'shrink-0 size-5', trailingIcon: 'shrink-0 size-5 ms-auto group-data-[state=open]:rotate-180 transition-transform duration-200', label: 'text-start break-words' }, variants: { disabled: { true: { trigger: 'cursor-not-allowed opacity-75' } } } } } }) ``` ## Changelog See the [releases page](https://github.com/nuxt/ui/releases) for the latest changes. --- # Source: https://ui.nuxt.com/raw/docs/components/alert.md # Alert > A callout to draw user's attention. ## Usage ### Title Use the `title` prop to set the title of the Alert. ```vue ``` ### Description Use the `description` prop to set the description of the Alert. ```vue ``` ### Icon Use the `icon` prop to show an [Icon](/docs/components/icon). ```vue ``` ### Avatar Use the `avatar` prop to show an [Avatar](/docs/components/avatar). ```vue ``` ### Color Use the `color` prop to change the color of the Alert. ```vue ``` ### Variant Use the `variant` prop to change the variant of the Alert. ```vue ``` ### Close Use the `close` prop to display a [Button](/docs/components/button) to dismiss the Alert. > [!TIP] > An `update:open` event will be emitted when the close button is clicked. ```vue ``` You can pass any property from the [Button](/docs/components/button) component to customize it. ```vue ``` ### Close Icon Use the `close-icon` prop to customize the close button [Icon](/docs/components/icon). Defaults to `i-lucide-x`. ```vue ``` **Nuxt:** > [!TIP] > See: /docs/getting-started/integrations/icons/nuxt#theme > You can customize this icon globally in your `app.config.ts` under `ui.icons.close` key. **Vue:** > [!TIP] > See: /docs/getting-started/integrations/icons/vue#theme > You can customize this icon globally in your `vite.config.ts` under `ui.icons.close` key. ### Actions Use the `actions` prop to add some [Button](/docs/components/button) actions to the Alert. ```vue ``` ### Orientation Use the `orientation` prop to change the orientation of the Alert. ```vue ``` ## Examples ### `class` prop Use the `class` prop to override the base styles of the Alert. ```vue ``` ### `ui` prop Use the `ui` prop to override the slots styles of the Alert. ```vue ``` ## API ### Props ```ts /** * Props for the Alert component */ interface AlertProps { /** * The element or component this component should render as. */ as?: any; title?: string | undefined; description?: string | undefined; icon?: any; avatar?: AvatarProps | undefined; color?: "error" | "primary" | "secondary" | "success" | "info" | "warning" | "neutral" | undefined; variant?: "solid" | "outline" | "soft" | "subtle" | undefined; /** * The orientation between the content and the actions. * @default "\"vertical\"" */ orientation?: "vertical" | "horizontal" | undefined; /** * Display a list of actions: * - under the title and description when orientation is `vertical` * - next to the close button when orientation is `horizontal` * `{ size: 'xs' }`{lang="ts-type"} */ actions?: ButtonProps[] | undefined; /** * Display a close button to dismiss the alert. * `{ size: 'md', color: 'neutral', variant: 'link' }`{lang="ts-type"} */ close?: boolean | Omit | undefined; /** * The icon displayed in the close button. */ closeIcon?: any; ui?: { root?: ClassNameValue; wrapper?: ClassNameValue; title?: ClassNameValue; description?: ClassNameValue; icon?: ClassNameValue; avatar?: ClassNameValue; avatarSize?: ClassNameValue; actions?: ClassNameValue; close?: ClassNameValue; } | undefined; } ``` ### Slots ```ts /** * Slots for the Alert component */ interface AlertSlots { leading(): any; title(): any; description(): any; actions(): any; close(): any; } ``` ### Emits ```ts /** * Emitted events for the Alert component */ interface AlertEmits { update:open: (payload: [value: boolean]) => void; } ``` ## Theme ```ts [app.config.ts] export default defineAppConfig({ ui: { alert: { slots: { root: 'relative overflow-hidden w-full rounded-lg p-4 flex gap-2.5', wrapper: 'min-w-0 flex-1 flex flex-col', title: 'text-sm font-medium', description: 'text-sm opacity-90', icon: 'shrink-0 size-5', avatar: 'shrink-0', avatarSize: '2xl', actions: 'flex flex-wrap gap-1.5 shrink-0', close: 'p-0' }, variants: { color: { primary: '', secondary: '', success: '', info: '', warning: '', error: '', neutral: '' }, variant: { solid: '', outline: '', soft: '', subtle: '' }, orientation: { horizontal: { root: 'items-center', actions: 'items-center' }, vertical: { root: 'items-start', actions: 'items-start mt-2.5' } }, title: { true: { description: 'mt-1' } } }, compoundVariants: [ { color: 'primary', variant: 'solid', class: { root: 'bg-primary text-inverted' } }, { color: 'secondary', variant: 'solid', class: { root: 'bg-secondary text-inverted' } }, { color: 'success', variant: 'solid', class: { root: 'bg-success text-inverted' } }, { color: 'info', variant: 'solid', class: { root: 'bg-info text-inverted' } }, { color: 'warning', variant: 'solid', class: { root: 'bg-warning text-inverted' } }, { color: 'error', variant: 'solid', class: { root: 'bg-error text-inverted' } }, { color: 'primary', variant: 'outline', class: { root: 'text-primary ring ring-inset ring-primary/25' } }, { color: 'secondary', variant: 'outline', class: { root: 'text-secondary ring ring-inset ring-secondary/25' } }, { color: 'success', variant: 'outline', class: { root: 'text-success ring ring-inset ring-success/25' } }, { color: 'info', variant: 'outline', class: { root: 'text-info ring ring-inset ring-info/25' } }, { color: 'warning', variant: 'outline', class: { root: 'text-warning ring ring-inset ring-warning/25' } }, { color: 'error', variant: 'outline', class: { root: 'text-error ring ring-inset ring-error/25' } }, { color: 'primary', variant: 'soft', class: { root: 'bg-primary/10 text-primary' } }, { color: 'secondary', variant: 'soft', class: { root: 'bg-secondary/10 text-secondary' } }, { color: 'success', variant: 'soft', class: { root: 'bg-success/10 text-success' } }, { color: 'info', variant: 'soft', class: { root: 'bg-info/10 text-info' } }, { color: 'warning', variant: 'soft', class: { root: 'bg-warning/10 text-warning' } }, { color: 'error', variant: 'soft', class: { root: 'bg-error/10 text-error' } }, { color: 'primary', variant: 'subtle', class: { root: 'bg-primary/10 text-primary ring ring-inset ring-primary/25' } }, { color: 'secondary', variant: 'subtle', class: { root: 'bg-secondary/10 text-secondary ring ring-inset ring-secondary/25' } }, { color: 'success', variant: 'subtle', class: { root: 'bg-success/10 text-success ring ring-inset ring-success/25' } }, { color: 'info', variant: 'subtle', class: { root: 'bg-info/10 text-info ring ring-inset ring-info/25' } }, { color: 'warning', variant: 'subtle', class: { root: 'bg-warning/10 text-warning ring ring-inset ring-warning/25' } }, { color: 'error', variant: 'subtle', class: { root: 'bg-error/10 text-error ring ring-inset ring-error/25' } }, { color: 'neutral', variant: 'solid', class: { root: 'text-inverted bg-inverted' } }, { color: 'neutral', variant: 'outline', class: { root: 'text-highlighted bg-default ring ring-inset ring-default' } }, { color: 'neutral', variant: 'soft', class: { root: 'text-highlighted bg-elevated/50' } }, { color: 'neutral', variant: 'subtle', class: { root: 'text-highlighted bg-elevated/50 ring ring-inset ring-accented' } } ], defaultVariants: { color: 'primary', variant: 'solid' } } } }) ``` ## Changelog See the [releases page](https://github.com/nuxt/ui/releases) for the latest changes. --- # Source: https://ui.nuxt.com/raw/docs/components/app.md # App > Wraps your app to provide global configurations and more. ## Usage This component implements Reka UI [ConfigProvider](https://reka-ui.com/docs/utilities/config-provider) to provide global configuration to all components: - Enables all primitives to inherit global reading direction. - Enables changing the behavior of scroll body when setting body lock. - Much more controls to prevent layout shifts. It's also using [ToastProvider](https://reka-ui.com/docs/components/toast#provider) and [TooltipProvider](https://reka-ui.com/docs/components/tooltip#provider) to provide global toasts and tooltips, as well as programmatic modals and slideovers. Wrap your entire application with the App component in your `app.vue` file: ```vue [app.vue] ``` **Nuxt:** > [!TIP] > See: /docs/getting-started/integrations/i18n/nuxt#locale > Learn how to use the `locale` prop to change the locale of your app. This also controls the date/time format in components like Calendar, InputDate, and InputTime. **Vue:** > [!TIP] > See: /docs/getting-started/integrations/i18n/vue#locale > Learn how to use the `locale` prop to change the locale of your app. This also controls the date/time format in components like Calendar, InputDate, and InputTime. ## API ### Props ```ts /** * Props for the App component */ interface AppProps { tooltip?: TooltipProviderProps | undefined; toaster?: ToasterProps | null | undefined; locale?: Locale | undefined; /** * @default "\"body\"" */ portal?: string | boolean | HTMLElement | undefined; /** * The global reading direction of your application. This will be inherited by all primitives. */ dir?: Direction | undefined; /** * The global scroll body behavior of your application. This will be inherited by the related primitives. */ scrollBody?: boolean | ScrollBodyOption | undefined; /** * The global `nonce` value of your application. This will be inherited by the related primitives. */ nonce?: string | undefined; } ``` ### Slots ```ts /** * Slots for the App component */ interface AppSlots { default(): any; } ``` ## Changelog See the [releases page](https://github.com/nuxt/ui/releases) for the latest changes. --- # Source: https://ui.nuxt.com/raw/docs/components/auth-form.md # AuthForm > A customizable Form to create login, register or password reset forms. ## Usage Built on top of the [Form](/docs/components/form) component, the `AuthForm` component can be used in your pages or wrapped in a [PageCard](/docs/components/page-card). ```vue [AuthFormExample.vue] ``` ### Fields The Form will construct itself based on the `fields` prop and the state will be handled internally. Use the `fields` prop as an array of objects with the following properties: - `name: string` - `type: 'checkbox' | 'select' | 'otp' | 'InputHTMLAttributes['type']'` Each field must include a `type` property, which determines the input component and any additional props applied: `checkbox` fields use [Checkbox](/docs/components/checkbox#props) props, `select` fields use [SelectMenu](/docs/components/select-menu#props) props, `otp` fields use [PinInput](/docs/components/pin-input#props) props, and all other types use [Input](/docs/components/input#props) props. You can also pass any property from the [FormField](/docs/components/form-field#props) component to each field. ```vue ``` ### Title Use the `title` prop to set the title of the Form. ```vue ``` ### Description Use the `description` prop to set the description of the Form. ```vue ``` ### Icon Use the `icon` prop to set the icon of the Form. ```vue ``` ### Providers Use the `providers` prop to add providers to the form. You can pass any property from the [Button](/docs/components/button) component such as `variant`, `color`, `to`, etc. ```vue ``` ### Separator Use the `separator` prop to customize the [Separator](/docs/components/separator) between the providers and the fields. Defaults to `or`. ```vue ``` You can pass any property from the [Separator](/docs/components/separator#props) component to customize it. ```vue ``` ### Submit Use the `submit` prop to change the submit button of the Form. You can pass any property from the [Button](/docs/components/button) component such as `variant`, `color`, `to`, etc. ```vue ``` ## Examples ### Within a page You can wrap the `AuthForm` component with the [PageCard](/docs/components/page-card) component to display it within a `login.vue` page for example. ```vue [AuthFormPageExample.vue] ``` ## API ### Props ```ts /** * Props for the AuthForm component */ interface AuthFormProps { /** * The element or component this component should render as. */ as?: any; /** * The icon displayed above the title. */ icon?: any; title?: string | undefined; description?: string | undefined; fields?: F[] | undefined; /** * Display a list of Button under the description. * `{ color: 'neutral', variant: 'subtle', block: true }`{lang="ts-type"} */ providers?: ButtonProps[] | undefined; /** * The text displayed in the separator. * @default "\"or\"" */ separator?: string | SeparatorProps | undefined; /** * Display a submit button at the bottom of the form. * `{ label: 'Continue', block: true }`{lang="ts-type"} */ submit?: Omit | undefined; schema?: T | undefined; validate?: ((state: Partial>) => FormError[] | Promise[]>) | undefined; validateOn?: FormInputEvents[] | undefined; validateOnInputDelay?: number | undefined; disabled?: boolean | undefined; loading?: boolean | undefined; loadingAuto?: boolean | undefined; ui?: { root?: ClassNameValue; header?: ClassNameValue; leading?: ClassNameValue; leadingIcon?: ClassNameValue; title?: ClassNameValue; description?: ClassNameValue; body?: ClassNameValue; providers?: ClassNameValue; checkbox?: ClassNameValue; select?: ClassNameValue; password?: ClassNameValue; otp?: ClassNameValue; input?: ClassNameValue; separator?: ClassNameValue; form?: ClassNameValue; footer?: ClassNameValue; } | undefined; name?: string | undefined; autocomplete?: string | undefined; acceptcharset?: string | undefined; action?: string | undefined; enctype?: string | undefined; method?: string | undefined; novalidate?: Booleanish | undefined; target?: string | undefined; } ``` > [!NOTE] > See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#attributes > This component also supports all native `
` HTML attributes. ### Slots ```ts /** * Slots for the AuthForm component */ interface AuthFormSlots { header(): any; leading(): any; title(): any; description(): any; providers(): any; validation(): any; submit(): any; footer(): any; } ``` ### Emits ```ts /** * Emitted events for the AuthForm component */ interface AuthFormEmits { submit: (payload: [payload: FormSubmitEvent>>]) => void; } ``` ### Expose You can access the typed component instance (exposing formRef and state) using [`useTemplateRef`](https://vuejs.org/api/composition-api-helpers.html#usetemplateref). For example, in a separate form (e.g. a "reset" form) you can do: ```vue ``` This gives you access to the following (exposed) properties:
Name Type
formRef Ref < HTMLFormElement | null >
state Reactive < FormStateType >
## Theme ```ts [app.config.ts] export default defineAppConfig({ ui: { authForm: { slots: { root: 'w-full space-y-6', header: 'flex flex-col text-center', leading: 'mb-2', leadingIcon: 'size-8 shrink-0 inline-block', title: 'text-xl text-pretty font-semibold text-highlighted', description: 'mt-1 text-base text-pretty text-muted', body: 'gap-y-6 flex flex-col', providers: 'space-y-3', checkbox: '', select: 'w-full', password: 'w-full', otp: 'w-full', input: 'w-full', separator: '', form: 'space-y-5', footer: 'text-sm text-center text-muted mt-2' } } } }) ``` ## Changelog See the [releases page](https://github.com/nuxt/ui/releases) for the latest changes. --- # Source: https://ui.nuxt.com/raw/docs/components/avatar-group.md # AvatarGroup > Stack multiple avatars in a group. ## Usage Wrap multiple [Avatar](/docs/components/avatar) within an AvatarGroup to stack them. ```vue ``` ### Size Use the `size` prop to change the size of all the avatars. ```vue ``` ### Max Use the `max` prop to limit the number of avatars displayed. The rest is displayed as an `+X` avatar. ```vue ``` ## Examples ### With tooltip Wrap each avatar with a [Tooltip](/docs/components/tooltip) to display a tooltip on hover. ```vue [AvatarGroupTooltipExample.vue] ``` ### With chip Wrap each avatar with a [Chip](/docs/components/chip) to display a chip around the avatar. ```vue [AvatarGroupChipExample.vue] ``` ### With link Wrap each avatar with a [Link](/docs/components/link) to make them clickable. ```vue [AvatarGroupLinkExample.vue] ``` ### With mask Wrap an avatar with a CSS mask to display it with a custom shape. ```vue [AvatarGroupMaskExample.vue] ``` > [!WARNING] > The `chip` prop does not work correctly when using a mask. Chips may be cut depending on the mask shape. ## API ### Props ```ts /** * Props for the AvatarGroup component */ interface AvatarGroupProps { /** * The element or component this component should render as. */ as?: any; size?: "md" | "xs" | "sm" | "lg" | "xl" | "3xs" | "2xs" | "2xl" | "3xl" | undefined; /** * The maximum number of avatars to display. */ max?: string | number | undefined; ui?: { root?: ClassNameValue; base?: ClassNameValue; } | undefined; } ``` ### Slots ```ts /** * Slots for the AvatarGroup component */ interface AvatarGroupSlots { default(): any; } ``` ## Theme ```ts [app.config.ts] export default defineAppConfig({ ui: { avatarGroup: { slots: { root: 'inline-flex flex-row-reverse justify-end', base: 'relative rounded-full ring-bg first:me-0' }, variants: { size: { '3xs': { base: 'ring -me-0.5' }, '2xs': { base: 'ring -me-0.5' }, xs: { base: 'ring -me-0.5' }, sm: { base: 'ring-2 -me-1.5' }, md: { base: 'ring-2 -me-1.5' }, lg: { base: 'ring-2 -me-1.5' }, xl: { base: 'ring-3 -me-2' }, '2xl': { base: 'ring-3 -me-2' }, '3xl': { base: 'ring-3 -me-2' } } }, defaultVariants: { size: 'md' } } } }) ``` ## Changelog See the [releases page](https://github.com/nuxt/ui/releases) for the latest changes. --- # Source: https://ui.nuxt.com/raw/docs/components/avatar.md # Avatar > An img element with fallback and Nuxt Image support. ## Usage The Avatar uses the `` component when [`@nuxt/image`](https://github.com/nuxt/image) is installed, falling back to `img` otherwise. ```vue ``` > [!NOTE] > You can pass any property from the HTML `` element such as `alt`, `loading`, etc. > [!TIP] > To opt-out of `@nuxt/image`, use the `as` prop: `:as="{ img: 'img' }"`. ### Src Use the `src` prop to set the image URL. ```vue ``` ### Size Use the `size` prop to set the size of the Avatar. ```vue ``` > [!NOTE] > The `` element's `width` and `height` are automatically set based on the `size` prop. ### Icon Use the `icon` prop to display a fallback [Icon](/docs/components/icon). ```vue ``` ### Text Use the `text` prop to display a fallback text. ```vue ``` ### Alt When no icon or text is provided, the **initials** of the `alt` prop is used as fallback. ```vue ``` > [!NOTE] > The `alt` prop is passed to the `img` element as the `alt` attribute. ### Chip Use the `chip` prop to display a chip around the Avatar. ```vue ``` ## Examples ### With tooltip You can use a [Tooltip](/docs/components/tooltip) component to display a tooltip when hovering the Avatar. ```vue [AvatarTooltipExample.vue] ``` ### With mask You can use a CSS mask to display an Avatar with a custom shape instead of a simple circle. ```vue [AvatarMaskExample.vue] ``` ## API ### Props ```ts /** * Props for the Avatar component */ interface AvatarProps { /** * The element or component this component should render as. */ as?: any; src?: string | undefined; alt?: string | undefined; icon?: any; text?: string | undefined; size?: "md" | "xs" | "sm" | "lg" | "xl" | "3xs" | "2xs" | "2xl" | "3xl" | undefined; chip?: boolean | ChipProps | undefined; ui?: { root?: ClassNameValue; image?: ClassNameValue; fallback?: ClassNameValue; icon?: ClassNameValue; } | undefined; loading?: "eager" | "lazy" | undefined; referrerpolicy?: HTMLAttributeReferrerPolicy | undefined; crossorigin?: "" | "anonymous" | "use-credentials" | undefined; decoding?: "async" | "auto" | "sync" | undefined; height?: Numberish | undefined; sizes?: string | undefined; srcset?: string | undefined; usemap?: string | undefined; width?: Numberish | undefined; } ``` > [!NOTE] > See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attributes > This component also supports all native `` HTML attributes. ## Theme ```ts [app.config.ts] export default defineAppConfig({ ui: { avatar: { slots: { root: 'inline-flex items-center justify-center shrink-0 select-none rounded-full align-middle bg-elevated', image: 'h-full w-full rounded-[inherit] object-cover', fallback: 'font-medium leading-none text-muted truncate', icon: 'text-muted shrink-0' }, variants: { size: { '3xs': { root: 'size-4 text-[8px]' }, '2xs': { root: 'size-5 text-[10px]' }, xs: { root: 'size-6 text-xs' }, sm: { root: 'size-7 text-sm' }, md: { root: 'size-8 text-base' }, lg: { root: 'size-9 text-lg' }, xl: { root: 'size-10 text-xl' }, '2xl': { root: 'size-11 text-[22px]' }, '3xl': { root: 'size-12 text-2xl' } } }, defaultVariants: { size: 'md' } } } }) ``` ## Changelog See the [releases page](https://github.com/nuxt/ui/releases) for the latest changes. --- # Source: https://ui.nuxt.com/raw/docs/components/badge.md # Badge > A short text to represent a status or a category. ## Usage Use the default slot to set the label of the Badge. ```vue ``` ### Label Use the `label` prop to set the label of the Badge. ```vue ``` ### Color Use the `color` prop to change the color of the Badge. ```vue ``` ### Variant Use the `variant` props to change the variant of the Badge. ```vue ``` ### Size Use the `size` prop to change the size of the Badge. ```vue ``` ### Icon Use the `icon` prop to show an [Icon](/docs/components/icon) inside the Badge. ```vue ``` Use the `leading` and `trailing` props to set the icon position or the `leading-icon` and `trailing-icon` props to set a different icon for each position. ```vue ``` ### Avatar Use the `avatar` prop to show an [Avatar](/docs/components/avatar) inside the Badge. ```vue ``` ## Examples ### `class` prop Use the `class` prop to override the base styles of the Badge. ```vue ``` ## API ### Props ```ts /** * Props for the Badge component */ interface BadgeProps { /** * The element or component this component should render as. * @default "\"span\"" */ as?: any; label?: string | number | undefined; color?: "error" | "primary" | "secondary" | "success" | "info" | "warning" | "neutral" | undefined; variant?: "solid" | "outline" | "soft" | "subtle" | undefined; size?: "xs" | "sm" | "md" | "lg" | "xl" | undefined; /** * Render the badge with equal padding on all sides. */ square?: boolean | undefined; ui?: { base?: ClassNameValue; label?: ClassNameValue; leadingIcon?: ClassNameValue; leadingAvatar?: ClassNameValue; leadingAvatarSize?: ClassNameValue; trailingIcon?: ClassNameValue; } | undefined; /** * Display an icon based on the `leading` and `trailing` props. */ icon?: any; /** * Display an avatar on the left side. */ avatar?: AvatarProps | undefined; /** * When `true`, the icon will be displayed on the left side. */ leading?: boolean | undefined; /** * Display an icon on the left side. */ leadingIcon?: any; /** * When `true`, the icon will be displayed on the right side. */ trailing?: boolean | undefined; /** * Display an icon on the right side. */ trailingIcon?: any; } ``` ### Slots ```ts /** * Slots for the Badge component */ interface BadgeSlots { leading(): any; default(): any; trailing(): any; } ``` ## Theme ```ts [app.config.ts] export default defineAppConfig({ ui: { badge: { slots: { base: 'font-medium inline-flex items-center', label: 'truncate', leadingIcon: 'shrink-0', leadingAvatar: 'shrink-0', leadingAvatarSize: '', trailingIcon: 'shrink-0' }, variants: { fieldGroup: { horizontal: 'not-only:first:rounded-e-none not-only:last:rounded-s-none not-last:not-first:rounded-none focus-visible:z-[1]', vertical: 'not-only:first:rounded-b-none not-only:last:rounded-t-none not-last:not-first:rounded-none focus-visible:z-[1]' }, color: { primary: '', secondary: '', success: '', info: '', warning: '', error: '', neutral: '' }, variant: { solid: '', outline: '', soft: '', subtle: '' }, size: { xs: { base: 'text-[8px]/3 px-1 py-0.5 gap-1 rounded-sm', leadingIcon: 'size-3', leadingAvatarSize: '3xs', trailingIcon: 'size-3' }, sm: { base: 'text-[10px]/3 px-1.5 py-1 gap-1 rounded-sm', leadingIcon: 'size-3', leadingAvatarSize: '3xs', trailingIcon: 'size-3' }, md: { base: 'text-xs px-2 py-1 gap-1 rounded-md', leadingIcon: 'size-4', leadingAvatarSize: '3xs', trailingIcon: 'size-4' }, lg: { base: 'text-sm px-2 py-1 gap-1.5 rounded-md', leadingIcon: 'size-5', leadingAvatarSize: '2xs', trailingIcon: 'size-5' }, xl: { base: 'text-base px-2.5 py-1 gap-1.5 rounded-md', leadingIcon: 'size-6', leadingAvatarSize: '2xs', trailingIcon: 'size-6' } }, square: { true: '' } }, compoundVariants: [ { color: 'primary', variant: 'solid', class: 'bg-primary text-inverted' }, { color: 'secondary', variant: 'solid', class: 'bg-secondary text-inverted' }, { color: 'success', variant: 'solid', class: 'bg-success text-inverted' }, { color: 'info', variant: 'solid', class: 'bg-info text-inverted' }, { color: 'warning', variant: 'solid', class: 'bg-warning text-inverted' }, { color: 'error', variant: 'solid', class: 'bg-error text-inverted' }, { color: 'primary', variant: 'outline', class: 'text-primary ring ring-inset ring-primary/50' }, { color: 'secondary', variant: 'outline', class: 'text-secondary ring ring-inset ring-secondary/50' }, { color: 'success', variant: 'outline', class: 'text-success ring ring-inset ring-success/50' }, { color: 'info', variant: 'outline', class: 'text-info ring ring-inset ring-info/50' }, { color: 'warning', variant: 'outline', class: 'text-warning ring ring-inset ring-warning/50' }, { color: 'error', variant: 'outline', class: 'text-error ring ring-inset ring-error/50' }, { color: 'primary', variant: 'soft', class: 'bg-primary/10 text-primary' }, { color: 'secondary', variant: 'soft', class: 'bg-secondary/10 text-secondary' }, { color: 'success', variant: 'soft', class: 'bg-success/10 text-success' }, { color: 'info', variant: 'soft', class: 'bg-info/10 text-info' }, { color: 'warning', variant: 'soft', class: 'bg-warning/10 text-warning' }, { color: 'error', variant: 'soft', class: 'bg-error/10 text-error' }, { color: 'primary', variant: 'subtle', class: 'bg-primary/10 text-primary ring ring-inset ring-primary/25' }, { color: 'secondary', variant: 'subtle', class: 'bg-secondary/10 text-secondary ring ring-inset ring-secondary/25' }, { color: 'success', variant: 'subtle', class: 'bg-success/10 text-success ring ring-inset ring-success/25' }, { color: 'info', variant: 'subtle', class: 'bg-info/10 text-info ring ring-inset ring-info/25' }, { color: 'warning', variant: 'subtle', class: 'bg-warning/10 text-warning ring ring-inset ring-warning/25' }, { color: 'error', variant: 'subtle', class: 'bg-error/10 text-error ring ring-inset ring-error/25' }, { color: 'neutral', variant: 'solid', class: 'text-inverted bg-inverted' }, { color: 'neutral', variant: 'outline', class: 'ring ring-inset ring-accented text-default bg-default' }, { color: 'neutral', variant: 'soft', class: 'text-default bg-elevated' }, { color: 'neutral', variant: 'subtle', class: 'ring ring-inset ring-accented text-default bg-elevated' }, { size: 'xs', square: true, class: 'p-0.5' }, { size: 'sm', square: true, class: 'p-1' }, { size: 'md', square: true, class: 'p-1' }, { size: 'lg', square: true, class: 'p-1' }, { size: 'xl', square: true, class: 'p-1' } ], defaultVariants: { color: 'primary', variant: 'solid', size: 'md' } } } }) ``` ## Changelog See the [releases page](https://github.com/nuxt/ui/releases) for the latest changes. --- # Source: https://ui.nuxt.com/raw/docs/components/banner.md # Banner > Display a banner at the top of your website to inform users about important information. ## Usage ### Title Use the `title` prop to display a title on the Banner. ```vue ``` ### Icon Use the `icon` prop to display an icon on the Banner. ```vue ``` ### Color Use the `color` prop to change the color of the Banner. ```vue ``` ### Close Use the `close` prop to display a [Button](/docs/components/button) to dismiss the Banner. Defaults to `false`. > [!TIP] > A `close` event will be emitted when the close button is clicked. ```vue [BannerExample.vue] ``` > [!NOTE] > When closed, `banner-${id}` will be stored in the local storage to prevent it from being displayed again. For the example above, `banner-example` will be stored in the local storage. > [!CAUTION] > To persist the dismissed state across page reloads, you must specify an `id` prop. Without an explicit `id`, the banner will only be hidden for the current session and will reappear on page reload. ### Close Icon Use the `close-icon` prop to customize the close button [Icon](/docs/components/icon). Defaults to `i-lucide-x`. ```vue [BannerExample.vue] ``` **Nuxt:** > [!TIP] > See: /docs/getting-started/integrations/icons/nuxt#theme > You can customize this icon globally in your `app.config.ts` under `ui.icons.close` key. **Vue:** > [!TIP] > See: /docs/getting-started/integrations/icons/vue#theme > You can customize this icon globally in your `vite.config.ts` under `ui.icons.close` key. ### Actions Use the `actions` prop to add some [Button](/docs/components/button) actions to the Banner. ```vue ``` > [!NOTE] > The action buttons default to `color="neutral"` and `size="xs"`. You can customize these values by passing them directly to each action button. ### Link You can pass any property from the [``](https://nuxt.com/docs/api/components/nuxt-link) component such as `to`, `target`, `rel`, etc. ```vue ``` > [!NOTE] > The `NuxtLink` component will inherit all other attributes you pass to the `User` component. ## Examples ### Within `app.vue` Use the Banner component in your `app.vue` or in a layout: ```vue [app.vue] ``` ## API ### Props ```ts /** * Props for the Banner component */ interface BannerProps { /** * The element or component this component should render as. */ as?: any; /** * A unique id saved to local storage to remember if the banner has been dismissed. * Without an explicit id, the banner will not be persisted and will reappear on page reload. */ id?: string | undefined; /** * The icon displayed next to the title. */ icon?: any; title?: string | undefined; /** * Display a list of actions next to the title. * `{ color: 'neutral', size: 'xs' }`{lang="ts-type"} */ actions?: ButtonProps[] | undefined; to?: string | kt | Tt | undefined; target?: "_blank" | "_parent" | "_self" | "_top" | (string & {}) | null | undefined; color?: "error" | "primary" | "secondary" | "success" | "info" | "warning" | "neutral" | undefined; /** * Display a close button to dismiss the banner. * `{ size: 'md', color: 'neutral', variant: 'ghost' }`{lang="ts-type"} */ close?: boolean | Omit | undefined; /** * The icon displayed in the close button. */ closeIcon?: any; ui?: { root?: ClassNameValue; container?: ClassNameValue; left?: ClassNameValue; center?: ClassNameValue; right?: ClassNameValue; icon?: ClassNameValue; title?: ClassNameValue; actions?: ClassNameValue; close?: ClassNameValue; } | undefined; } ``` ### Slots ```ts /** * Slots for the Banner component */ interface BannerSlots { leading(): any; title(): any; actions(): any; close(): any; } ``` ### Emits ```ts /** * Emitted events for the Banner component */ interface BannerEmits { close: (payload: []) => void; } ``` ## Theme ```ts [app.config.ts] export default defineAppConfig({ ui: { banner: { slots: { root: [ 'relative z-50 w-full', 'transition-colors' ], container: 'flex items-center justify-between gap-3 h-12', left: 'hidden lg:flex-1 lg:flex lg:items-center', center: 'flex items-center gap-1.5 min-w-0', right: 'lg:flex-1 flex items-center justify-end', icon: 'size-5 shrink-0 text-inverted pointer-events-none', title: 'text-sm text-inverted font-medium truncate', actions: 'flex gap-1.5 shrink-0 isolate', close: 'text-inverted hover:bg-default/10 focus-visible:bg-default/10 -me-1.5 lg:me-0' }, variants: { color: { primary: { root: 'bg-primary' }, secondary: { root: 'bg-secondary' }, success: { root: 'bg-success' }, info: { root: 'bg-info' }, warning: { root: 'bg-warning' }, error: { root: 'bg-error' }, neutral: { root: 'bg-inverted' } }, to: { true: '' } }, compoundVariants: [ { color: 'primary', to: true, class: { root: 'hover:bg-primary/90' } }, { color: 'secondary', to: true, class: { root: 'hover:bg-secondary/90' } }, { color: 'success', to: true, class: { root: 'hover:bg-success/90' } }, { color: 'info', to: true, class: { root: 'hover:bg-info/90' } }, { color: 'warning', to: true, class: { root: 'hover:bg-warning/90' } }, { color: 'error', to: true, class: { root: 'hover:bg-error/90' } }, { color: 'neutral', to: true, class: { root: 'hover:bg-inverted/90' } } ], defaultVariants: { color: 'primary' } } } }) ``` ## Changelog See the [releases page](https://github.com/nuxt/ui/releases) for the latest changes. --- # Source: https://ui.nuxt.com/raw/docs/components/blog-post.md # BlogPost > A customizable article to display in a blog page. ## Usage The BlogPost component provides a flexible way to display an `
` element with customizable content including title, description, image, etc. ```vue ``` > [!TIP] > See: /docs/components/blog-posts > Use the `BlogPosts` component to display multiple blog posts in a responsive grid layout. ### Title Use the `title` prop to display the title of the BlogPost. ```vue ``` ### Description Use the `description` prop to display the description of the BlogPost. ```vue ``` ### Date Use the `date` prop to display the date of the BlogPost. > [!TIP] > The date is automatically formatted to the [current locale](/docs/getting-started/integrations/i18n/nuxt#locale). You can either pass a `Date` object or a string. ```vue ``` ### Badge Use the `badge` prop to display a [Badge](/docs/components/badge) in the BlogPost. ```vue ``` You can pass any property from the [Badge](/docs/components/badge#props) component to customize it. ```vue ``` ### Image Use the `image` prop to display an image in the BlogPost. > [!NOTE] > If [`@nuxt/image`](https://image.nuxt.com/get-started/installation) is installed, the `` component will be used instead of the native `img` tag. ```vue ``` ### Authors Use the `authors` prop to display a list of [User](/docs/components/user) in the BlogPost as an array of objects with the following properties: - `name?: string` - `description?: string` - `avatar?: Omit` - `chip?: boolean | Omit` - `size?: UserProps['size']` - `orientation?: UserProps['orientation']` You can pass any property from the [Link](/docs/components/link#props) component such as `to`, `target`, etc. ```vue ``` When the `authors` prop has more than one item, the [AvatarGroup](/docs/components/avatar-group) component is used. ```vue ``` ### Link You can pass any property from the [``](https://nuxt.com/docs/api/components/nuxt-link) component such as `to`, `target`, `rel`, etc. ```vue ``` ### Variant Use the `variant` prop to change the style of the BlogPost. ```vue ``` > [!NOTE] > The styling will be different wether you provide a `to` prop or an `image`. ### Orientation Use the `orientation` prop to change the BlogPost orientation. Defaults to `vertical`. ```vue ``` ## API ### Props ```ts /** * Props for the BlogPost component */ interface BlogPostProps { /** * The element or component this component should render as. * @default "\"article\"" */ as?: any; title?: string | undefined; description?: string | undefined; /** * The date of the blog post. Can be a string or a Date object. */ date?: string | Date | undefined; /** * Display a badge on the blog post. * Can be a string or an object. * `{ color: 'neutral', variant: 'subtle' }`{lang="ts-type"} */ badge?: string | BadgeProps | undefined; /** * The authors of the blog post. */ authors?: UserProps[] | undefined; /** * The image of the blog post. Can be a string or an object. */ image?: string | (Partial & { [key: string]: any; }) | undefined; /** * The orientation of the blog post. * @default "\"vertical\"" */ orientation?: "vertical" | "horizontal" | undefined; variant?: "outline" | "soft" | "subtle" | "ghost" | "naked" | undefined; to?: string | kt | Tt | undefined; target?: "_blank" | "_parent" | "_self" | "_top" | (string & {}) | null | undefined; onClick?: ((event: MouseEvent) => void | Promise) | undefined; ui?: { root?: ClassNameValue; header?: ClassNameValue; body?: ClassNameValue; footer?: ClassNameValue; image?: ClassNameValue; title?: ClassNameValue; description?: ClassNameValue; authors?: ClassNameValue; avatar?: ClassNameValue; meta?: ClassNameValue; date?: ClassNameValue; badge?: ClassNameValue; } | undefined; } ``` ### Slots ```ts /** * Slots for the BlogPost component */ interface BlogPostSlots { date(): any; badge(): any; title(): any; description(): any; authors(): any; header(): any; body(): any; footer(): any; } ``` ## Theme ```ts [app.config.ts] export default defineAppConfig({ ui: { blogPost: { slots: { root: 'relative group/blog-post flex flex-col rounded-lg overflow-hidden', header: 'relative overflow-hidden aspect-[16/9] w-full pointer-events-none', body: 'min-w-0 flex-1 flex flex-col', footer: '', image: 'object-cover object-top w-full h-full', title: 'text-xl text-pretty font-semibold text-highlighted', description: 'mt-1 text-base text-pretty', authors: 'pt-4 mt-auto flex flex-wrap gap-x-3 gap-y-1.5', avatar: '', meta: 'flex items-center gap-2 mb-2', date: 'text-sm', badge: '' }, variants: { orientation: { horizontal: { root: 'lg:grid lg:grid-cols-2 lg:items-center gap-x-8', body: 'justify-center p-4 sm:p-6 lg:px-0' }, vertical: { root: 'flex flex-col', body: 'p-4 sm:p-6' } }, variant: { outline: { root: 'bg-default ring ring-default', date: 'text-toned', description: 'text-muted' }, soft: { root: 'bg-elevated/50', date: 'text-muted', description: 'text-toned' }, subtle: { root: 'bg-elevated/50 ring ring-default', date: 'text-muted', description: 'text-toned' }, ghost: { date: 'text-toned', description: 'text-muted', header: 'shadow-lg rounded-lg' }, naked: { root: 'p-0 sm:p-0', date: 'text-toned', description: 'text-muted', header: 'shadow-lg rounded-lg' } }, to: { true: { root: [ 'has-focus-visible:ring-2 has-focus-visible:ring-primary', 'transition' ], image: 'transform transition-transform duration-200 group-hover/blog-post:scale-110', avatar: 'transform transition-transform duration-200 hover:scale-115 focus-visible:outline-primary' } }, image: { true: '' } }, compoundVariants: [ { variant: 'outline', to: true, class: { root: 'hover:bg-elevated/50' } }, { variant: 'soft', to: true, class: { root: 'hover:bg-elevated' } }, { variant: 'subtle', to: true, class: { root: 'hover:bg-elevated hover:ring-accented' } }, { variant: 'ghost', to: true, class: { root: 'hover:bg-elevated/50', header: [ 'group-hover/blog-post:shadow-none', 'transition-all' ] } }, { variant: 'ghost', to: true, orientation: 'vertical', class: { header: 'group-hover/blog-post:rounded-b-none' } }, { variant: 'ghost', to: true, orientation: 'horizontal', class: { header: 'group-hover/blog-post:rounded-r-none' } }, { orientation: 'vertical', image: false, variant: 'naked', class: { body: 'p-0 sm:p-0' } } ], defaultVariants: { variant: 'outline' } } } }) ``` ## Changelog See the [releases page](https://github.com/nuxt/ui/releases) for the latest changes. --- # Source: https://ui.nuxt.com/raw/docs/components/blog-posts.md # BlogPosts > Display a list of blog posts in a responsive grid layout. ## Usage The BlogPosts component provides a flexible layout to display a list of [BlogPost](/docs/components/blog-post) components using either the default slot or the `posts` prop. ```vue ``` ### Posts Use the `posts` prop as an array of objects with the properties of the [BlogPost](/docs/components/blog-post#props) component. ```vue ``` ### Orientation Use the `orientation` prop to change the orientation of the BlogPosts. Defaults to `horizontal`. ```vue ``` > [!TIP] > When using the `posts` prop instead of the default slot, the `orientation` of the posts is automatically reversed, `horizontal` to `vertical` and vice versa. ## Examples > [!NOTE] > While these examples use [Nuxt Content](https://content.nuxt.com), the components can be integrated with any content management system. ### Within a page Use the BlogPosts component in a page to create a blog page: ```vue [pages/blog/index.vue] ``` > [!NOTE] > In this example, the `posts` are fetched using `queryCollection` from the `@nuxt/content` module. > [!TIP] > The `to` prop is overridden here since `@nuxt/content` uses the `path` property. ## API ### Props ```ts /** * Props for the BlogPosts component */ interface BlogPostsProps { /** * The element or component this component should render as. */ as?: any; posts?: BlogPostProps[] | undefined; /** * The orientation of the blog posts. * @default "\"horizontal\"" */ orientation?: "horizontal" | "vertical" | undefined; } ``` ### Slots ```ts /** * Slots for the BlogPosts component */ interface BlogPostsSlots { date(): any; badge(): any; title(): any; description(): any; authors(): any; header(): any; body(): any; footer(): any; default(): any; } ``` ## Theme ```ts [app.config.ts] export default defineAppConfig({ ui: { blogPosts: { base: 'flex flex-col gap-8 lg:gap-y-16', variants: { orientation: { horizontal: 'sm:grid sm:grid-cols-2 lg:grid-cols-3', vertical: '' } } } } }) ``` ## Changelog See the [releases page](https://github.com/nuxt/ui/releases) for the latest changes. --- # Source: https://ui.nuxt.com/raw/docs/components/breadcrumb.md # Breadcrumb > A hierarchy of links to navigate through a website. ## Usage Use the Breadcrumb component to show the current page's location in your site's hierarchy. ```vue ``` ### Items Use the `items` prop as an array of objects with the following properties: - `label?: string` - `icon?: string` - `avatar?: AvatarProps` - [`slot?: string`](#with-custom-slot) - `class?: any` - `ui?: { item?: ClassNameValue, link?: ClassNameValue, linkLeadingIcon?: ClassNameValue, linkLeadingAvatar?: ClassNameValue, linkLabel?: ClassNameValue, separator?: ClassNameValue, separatorIcon?: ClassNameValue }` You can pass any property from the [Link](/docs/components/link#props) component such as `to`, `target`, etc. ```vue ``` > [!NOTE] > A `span` is rendered instead of a link when the `to` property is not defined. ### Separator Icon Use the `separator-icon` prop to customize the [Icon](/docs/components/icon) between each item. Defaults to `i-lucide-chevron-right`. ```vue ``` **Nuxt:** > [!TIP] > See: /docs/getting-started/integrations/icons/nuxt#theme > You can customize this icon globally in your `app.config.ts` under `ui.icons.chevronRight` key. **Vue:** > [!TIP] > See: /docs/getting-started/integrations/icons/vue#theme > You can customize this icon globally in your `vite.config.ts` under `ui.icons.chevronRight` key. ## Examples ### With separator slot Use the `#separator` slot to customize the separator between each item. ```vue [BreadcrumbSeparatorSlotExample.vue] ``` ### With custom slot Use the `slot` property to customize a specific item. You will have access to the following slots: - `#{{ item.slot }}` - `#{{ item.slot }}-leading` - `#{{ item.slot }}-label` - `#{{ item.slot }}-trailing` ```vue [BreadcrumbCustomSlotExample.vue] ``` > [!TIP] > See: #slots > You can also use the `#item`, `#item-leading`, `#item-label` and `#item-trailing` slots to customize all items. ## API ### Props ```ts /** * Props for the Breadcrumb component */ interface BreadcrumbProps { /** * The element or component this component should render as. * @default "\"nav\"" */ as?: any; items?: T[] | undefined; /** * The icon to use as a separator. */ separatorIcon?: any; /** * The key used to get the label from the item. * @default "\"label\"" */ labelKey?: GetItemKeys | undefined; ui?: { root?: ClassNameValue; list?: ClassNameValue; item?: ClassNameValue; link?: ClassNameValue; linkLeadingIcon?: ClassNameValue; linkLeadingAvatar?: ClassNameValue; linkLeadingAvatarSize?: ClassNameValue; linkLabel?: ClassNameValue; separator?: ClassNameValue; separatorIcon?: ClassNameValue; } | undefined; } ``` ### Slots ```ts /** * Slots for the Breadcrumb component */ interface BreadcrumbSlots { item(): any; item-leading(): any; item-label(): any; item-trailing(): any; separator(): any; } ``` ## Theme ```ts [app.config.ts] export default defineAppConfig({ ui: { breadcrumb: { slots: { root: 'relative min-w-0', list: 'flex items-center gap-1.5', item: 'flex min-w-0', link: 'group relative flex items-center gap-1.5 text-sm min-w-0 focus-visible:outline-primary', linkLeadingIcon: 'shrink-0 size-5', linkLeadingAvatar: 'shrink-0', linkLeadingAvatarSize: '2xs', linkLabel: 'truncate', separator: 'flex', separatorIcon: 'shrink-0 size-5 text-muted' }, variants: { active: { true: { link: 'text-primary font-semibold' }, false: { link: 'text-muted font-medium' } }, disabled: { true: { link: 'cursor-not-allowed opacity-75' } }, to: { true: '' } }, compoundVariants: [ { disabled: false, active: false, to: true, class: { link: [ 'hover:text-default', 'transition-colors' ] } } ] } } }) ``` ## Changelog See the [releases page](https://github.com/nuxt/ui/releases) for the latest changes. --- # Source: https://ui.nuxt.com/raw/docs/components/button.md # Button > A button element that can act as a link or trigger an action. ## Usage Use the default slot to set the label of the Button. ```vue ``` ### Label Use the `label` prop to set the label of the Button. ```vue ``` ### Color Use the `color` prop to change the color of the Button. ```vue ``` ### Variant Use the `variant` prop to change the variant of the Button. ```vue ``` ### Size Use the `size` prop to change the size of the Button. ```vue ``` ### Icon Use the `icon` prop to show an [Icon](/docs/components/icon) inside the Button. ```vue ``` Use the `leading` and `trailing` props to set the icon position or the `leading-icon` and `trailing-icon` props to set a different icon for each position. ```vue ``` The `label` as prop or slot is optional so you can use the Button as an icon-only button. ```vue ``` ### Avatar Use the `avatar` prop to show an [Avatar](/docs/components/avatar) inside the Button. ```vue ``` The `label` as prop or slot is optional so you can use the Button as an avatar-only button. ```vue ``` ### Link You can pass any property from the [Link](/docs/components/link#props) component such as `to`, `target`, etc. ```vue ``` When the Button is a link or when using the `active` prop, you can use the `active-color` and `active-variant` props to customize the active state. ```vue ``` You can also use the `active-class` and `inactive-class` props to customize the active state. ```vue ``` > [!TIP] > You can configure these styles globally in your `app.config.ts` file under the `ui.button.variants.active` key. > ```ts > export default defineAppConfig({ > ui: { > button: { > variants: { > active: { > true: { > base: 'font-bold' > } > } > } > } > } > }) > > ``` ### Loading Use the `loading` prop to show a loading icon and disable the Button. ```vue ``` Use the `loading-auto` prop to show the loading icon automatically while the `@click` promise is pending. ```vue [ButtonLoadingAutoExample.vue] ``` This also works with the [Form](/docs/components/form) component. ```vue [ButtonLoadingAutoFormExample.vue] ``` ### Loading Icon Use the `loading-icon` prop to customize the loading icon. Defaults to `i-lucide-loader-circle`. ```vue ``` **Nuxt:** > [!TIP] > See: /docs/getting-started/integrations/icons/nuxt#theme > You can customize this icon globally in your `app.config.ts` under `ui.icons.loading` key. **Vue:** > [!TIP] > See: /docs/getting-started/integrations/icons/vue#theme > You can customize this icon globally in your `vite.config.ts` under `ui.icons.loading` key. ### Disabled Use the `disabled` prop to disable the Button. ```vue ``` ## Examples ### `class` prop Use the `class` prop to override the base styles of the Button. ```vue ``` ### `ui` prop Use the `ui` prop to override the slots styles of the Button. ```vue ``` ## API ### Props ```ts /** * Props for the Button component */ interface ButtonProps { label?: string | undefined; color?: "error" | "primary" | "secondary" | "success" | "info" | "warning" | "neutral" | undefined; activeColor?: "error" | "primary" | "secondary" | "success" | "info" | "warning" | "neutral" | undefined; variant?: "solid" | "outline" | "soft" | "subtle" | "ghost" | "link" | undefined; activeVariant?: "solid" | "outline" | "soft" | "subtle" | "ghost" | "link" | undefined; size?: "xs" | "sm" | "md" | "lg" | "xl" | undefined; /** * Render the button with equal padding on all sides. */ square?: boolean | undefined; /** * Render the button full width. */ block?: boolean | undefined; /** * Set loading state automatically based on the `@click` promise state */ loadingAuto?: boolean | undefined; onClick?: ((event: MouseEvent) => void | Promise) | ((event: MouseEvent) => void | Promise)[] | undefined; ui?: { base?: ClassNameValue; label?: ClassNameValue; leadingIcon?: ClassNameValue; leadingAvatar?: ClassNameValue; leadingAvatarSize?: ClassNameValue; trailingIcon?: ClassNameValue; } | undefined; /** * Display an icon based on the `leading` and `trailing` props. */ icon?: any; /** * Display an avatar on the left side. */ avatar?: AvatarProps | undefined; /** * When `true`, the icon will be displayed on the left side. */ leading?: boolean | undefined; /** * Display an icon on the left side. */ leadingIcon?: any; /** * When `true`, the icon will be displayed on the right side. */ trailing?: boolean | undefined; /** * Display an icon on the right side. */ trailingIcon?: any; /** * When `true`, the loading icon will be displayed. */ loading?: boolean | undefined; /** * The icon when the `loading` prop is `true`. */ loadingIcon?: any; /** * Route Location the link should navigate to when clicked on. */ to?: string | kt | Tt | undefined; /** * Class to apply when the link is active */ activeClass?: string | undefined; /** * Class to apply when the link is exact active */ exactActiveClass?: string | undefined; /** * Value passed to the attribute `aria-current` when the link is exact active. */ ariaCurrentValue?: "page" | "step" | "location" | "date" | "time" | "true" | "false" | undefined; /** * Pass the returned promise of `router.push()` to `document.startViewTransition()` if supported. */ viewTransition?: boolean | undefined; /** * Calls `router.replace` instead of `router.push`. */ replace?: boolean | undefined; autofocus?: Booleanish | undefined; disabled?: boolean | undefined; form?: string | undefined; formaction?: string | undefined; formenctype?: string | undefined; formmethod?: string | undefined; formnovalidate?: Booleanish | undefined; formtarget?: string | undefined; name?: string | undefined; /** * The type of the button when not a link. */ type?: "reset" | "submit" | "button" | undefined; download?: any; /** * An alias for `to`. If used with `to`, `href` will be ignored */ href?: string | kt | Tt | undefined; hreflang?: string | undefined; media?: string | undefined; ping?: string | undefined; /** * A rel attribute value to apply on the link. Defaults to "noopener noreferrer" for external links. */ rel?: "noopener" | "noreferrer" | "nofollow" | "sponsored" | "ugc" | (string & {}) | null | undefined; /** * Where to display the linked URL, as the name for a browsing context. */ target?: (string & {}) | "_blank" | "_parent" | "_self" | "_top" | null | undefined; referrerpolicy?: HTMLAttributeReferrerPolicy | undefined; /** * The element or component this component should render as when not a link. */ as?: any; /** * Force the link to be active independent of the current route. */ active?: boolean | undefined; /** * Will only be active if the current route is an exact match. */ exact?: boolean | undefined; /** * Allows controlling how the current route query sets the link as active. */ exactQuery?: boolean | "partial" | undefined; /** * Will only be active if the current route hash is an exact match. */ exactHash?: boolean | undefined; /** * The class to apply when the link is inactive. */ inactiveClass?: string | undefined; /** * Forces the link to be considered as external (true) or internal (false). This is helpful to handle edge-cases */ external?: boolean | undefined; /** * If set to true, no rel attribute will be added to the link */ noRel?: boolean | undefined; /** * A class to apply to links that have been prefetched. */ prefetchedClass?: string | undefined; /** * When enabled will prefetch middleware, layouts and payloads of links in the viewport. */ prefetch?: boolean | undefined; /** * Allows controlling when to prefetch links. By default, prefetch is triggered only on visibility. */ prefetchOn?: "visibility" | "interaction" | Partial<{ visibility: boolean; interaction: boolean; }> | undefined; /** * Escape hatch to disable `prefetch` attribute. */ noPrefetch?: boolean | undefined; /** * An option to either add or remove trailing slashes in the `href` for this specific link. * Overrides the global `trailingSlash` option if provided. */ trailingSlash?: "remove" | "append" | undefined; } ``` > [!NOTE] > See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attributes > This component also supports all native `