Accordion
Set of interactive collapsible sections.
Preview
Installation
npx sigma-ui@latest add accordionUsage
<script setup lang="ts">
import {
Accordion,
AccordionContent,
AccordionItem,
AccordionTrigger,
} from '@/components/ui/accordion';
</script>
<template>
<Accordion
type="single"
collapsible
default-value="item-1"
>
<AccordionItem value="item-1">
<AccordionTrigger>Is it accessible?</AccordionTrigger>
<AccordionContent>
Yes. It adheres to the WAI-ARIA design pattern.
</AccordionContent>
</AccordionItem>
</Accordion>
</template>- Use
defaultValueto open an item initially, orv-modelto control the open item(s). - With
type="single", one item is open at a time andv-modelis astring. - With
type="multiple", several items can be open andv-modelis astring[].
Examples
Basic
Displays a single item, collapsed by default, with no defaultValue or v-model.
Multiple
Displays multiple expanded items at once, controlled through v-model.
API Reference
Accordion
Props
| Prop | Type | Default |
|---|---|---|
collapsibleWhen type is "single", allows closing content when clicking trigger for an open item. When type is "multiple", this prop has no effect. | boolean | false |
disabledWhen | boolean | false |
dirThe reading direction of the accordion when applicable. If omitted, assumes LTR (left-to-right) reading mode. | Direction | "ltr" |
orientationThe orientation of the accordion. | DataOrientation | "vertical" |
unmountOnHideWhen | boolean | `true` |
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
typeDetermines whether a "single" or "multiple" items can be selected at a time. This prop will overwrite the inferred type from | SingleOrMultipleType | - |
modelValueThe controlled value of the active item(s). Use this when you need to control the state of the items. Can be binded with | string | string[] | - |
defaultValueThe default active value of the item(s). Use when you do not need to control the state of the item(s). | string | string[] | - |
Events
| Event | Payload |
|---|---|
update:modelValueEvent handler called when the expanded state of an item changes | [value: string | string[]] |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
AccordionContent
Props
| Prop | Type | Default |
|---|---|---|
forceMountUsed to force mounting when more control is needed. Useful when controlling animation with Vue animation libraries. | boolean | - |
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
AccordionItem
Props
| Prop | Type | Default |
|---|---|---|
disabledWhether or not an accordion item is disabled from user interaction.
When | boolean | false |
valuerequiredA string value for the accordion item. All items within an accordion should use a unique value. | string | - |
unmountOnHideWhen | boolean | - |
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe content of the component. | - |
AccordionTrigger
Props
| Prop | Type | Default |
|---|---|---|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. | boolean | - |
asThe element or component this component should render as. Can be overwritten by | AsTag | Component | "div" |
Slots
| Slot | Scope |
|---|---|
defaultThe trigger label. | - |
iconReplaces the chevron icon that rotates when the item opens. | - |
Accessibility
Adheres to the Accordion WAI-ARIA design pattern.
| Key | Description |
|---|---|
| Space | When focus is on the trigger of a collapsed section, expands the section. |
| Enter | When focus is on the trigger of a collapsed section, expands the section. |
| Tab | Moves focus to the next focusable element. |
| Shift + Tab | Moves focus to the previous focusable element. |
| ArrowDown | Moves focus to the next trigger. |
| ArrowUp | Moves focus to the previous trigger. |
| Home | When focus is on a trigger, moves focus to the first trigger. |
| End | When focus is on a trigger, moves focus to the last trigger. |