Components
Accordion
A vertically stacked set of interactive headings that each reveal an associated section of content.
Source code
Click to see the source code for this component on GitHub. Feel free to copy it and adjust it for your own use.
Anatomy
Pass a list of items to the component.
Accordion Anatomy.vue
<template>
<UiAccordion :items />
</template>
<script lang="ts" setup>
const items = [];
</script>
Or use each part individually
Accordion Anatomy.vue
<template>
<UiAccordion>
<UiAccordionItem>
<UiAccordionHeader>
<UiAccordionTrigger />
</UiAccordionHeader>
<UiAccordionContent />
</UiAccordionItem>
</UiAccordion>
</template>
Installation
Usage
Basic
The most common way to use the accordion is by just passing an array of items to the items prop. Each item should have a value, title, and content.
Custom styling
If you want to change the way that the items look, you can do so by using the different components that the accordion is composed of.
Custom icon
You can change the icon that is displayed based on the open state of an item. Just override the the trigger slot and then override the icon slot.
Origin UI Examples
These are some examples that I found today over here Origin UI. I think they are cool.
To use these examples you will have to copy the code and adjust it for your own use.
With Chevron
With Chevron Left
With Chevron & Icon
With Sub-Header & Chevron
With Icon, Sub-Header & Chevron
Tabs with Chevron
Tabs with Left Chevron
Table with Chevron
Table with Left Chevron
Multi-Level
API Reference
Accordion Root
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
collapsible | boolean | undefined | true | No | When type is "single", allows closing content when clicking trigger for an open item. When type is "multiple", this prop has no effect. |
disabled | boolean | undefined | — | No | When `true`, prevents the user from interacting with the accordion and all its items |
dir | Direction | undefined | — | No | The reading direction of the accordion when applicable. If omitted, assumes LTR (left-to-right) reading mode. |
orientation | DataOrientation | undefined | — | No | The orientation of the accordion. |
unmountOnHide | boolean | undefined | — | No | When `true`, the element will be unmounted on closed state. |
asChild | boolean | undefined | — | No | Change the default rendered element for the one passed as a child, merging their props and behavior. Read our [Composition](https://www.reka-ui.com/docs/guides/composition) guide for more details. |
as | AsTag | Component | undefined | — | No | The element or component this component should render as. Can be overwritten by `asChild`. |
type | SingleOrMultipleType | undefined | "single" | No | Determines whether a "single" or "multiple" items can be selected at a time. This prop will overwrite the inferred type from `modelValue` and `defaultValue`. |
modelValue | string | string[] | undefined | — | No | 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` |
defaultValue | string | string[] | undefined | — | No | The default active value of the item(s). Use when you do not need to control the state of the item(s). |
items | AccordionItem[] | undefined | [] | No | No description provided. |
Accordion Content
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
forceMount | boolean | undefined | — | No | Used to force mounting when more control is needed. Useful when controlling animation with Vue animation libraries. |
asChild | boolean | undefined | — | No | Change the default rendered element for the one passed as a child, merging their props and behavior. Read our [Composition](https://www.reka-ui.com/docs/guides/composition) guide for more details. |
as | AsTag | Component | undefined | — | No | The element or component this component should render as. Can be overwritten by `asChild`. |
content | any | — | No | The content of the accordion. |
Accordion Header
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
asChild | boolean | undefined | — | No | Change the default rendered element for the one passed as a child, merging their props and behavior. Read our [Composition](https://www.reka-ui.com/docs/guides/composition) guide for more details. |
as | AsTag | Component | undefined | — | No | The element or component this component should render as. Can be overwritten by `asChild`. |
Accordion Item
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
value | string | — | Yes | A string value for the accordion item. All items within an accordion should use a unique value. |
disabled | boolean | undefined | — | No | Whether or not an accordion item is disabled from user interaction. When `true`, prevents the user from interacting with the item. |
unmountOnHide | boolean | undefined | — | No | When `true`, the element will be unmounted on closed state. |
asChild | boolean | undefined | — | No | Change the default rendered element for the one passed as a child, merging their props and behavior. Read our [Composition](https://www.reka-ui.com/docs/guides/composition) guide for more details. |
as | AsTag | Component | undefined | — | No | The element or component this component should render as. Can be overwritten by `asChild`. |
Accordion Trigger
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
asChild | boolean | undefined | — | No | Change the default rendered element for the one passed as a child, merging their props and behavior. Read our [Composition](https://www.reka-ui.com/docs/guides/composition) guide for more details. |
as | AsTag | Component | undefined | — | No | The element or component this component should render as. Can be overwritten by `asChild`. |
title | string | undefined | "" | No | The title of the accordion trigger. |
icon | string | undefined | "lucide:chevron-down" | No | The icon to show next to the title. |