Accordion
A set of collapsible panels with headings. There is no border. An open trigger rests on the wash, and hover and focus shift that wash. The root is rounded. The trigger and panel are Regular.
Anatomy
<UiAccordionRoot>
<UiAccordionItem value="item">
<UiAccordionHeader>
<UiAccordionTrigger>Title</UiAccordionTrigger>
</UiAccordionHeader>
<UiAccordionPanel>Body</UiAccordionPanel>
</UiAccordionItem>
</UiAccordionRoot>
Examples
Open multiple panels
Pass multiple so several panels can stay open at once.
Hidden until found
hiddenUntilFound hides closed panels with hidden="until-found" so find-in-page can still search them. Search for “restocking” to open the matching panel. Closed panels stay mounted, which also keeps their contents indexable.
Disabled item
disabled on an item (or on Root for the whole accordion) sets data-disabled and ignores presses.
API reference
Root
Groups all parts of the accordion. Renders a <div>.
| Prop | Type | Default | Description |
|---|---|---|---|
defaultValue | string[] | [] | Uncontrolled expanded item values. |
value | string[] | — | Controlled expanded values (v-model:value). |
multiple | boolean | false | Allow more than one panel open. |
disabled | boolean | false | Ignore interaction on every item. |
hiddenUntilFound | boolean | false | Apply hidden="until-found" to closed panels. Overrides keepMounted. |
keepMounted | boolean | true | Keep closed panels in the DOM so the height transition can run. Ignored when hiddenUntilFound is set. |
| Attribute | Description |
|---|---|
data-disabled | Present when the accordion is disabled. |
data-orientation | Always vertical. |
Item
Groups a header with its panel. Renders a <div>.
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | generated id | Unique id for this item. Required when controlling value on Root. |
disabled | boolean | false | Ignore interaction on this item. |
| Attribute | Description |
|---|---|
data-open | Present when this item is open. |
data-disabled | Present when this item is disabled. |
data-index | Zero-based index in the accordion. |
Header
Heading that labels the panel. Renders an <h3>.
| Attribute | Description |
|---|---|
data-open | Present when the item is open. |
data-disabled | Present when the item is disabled. |
data-index | Zero-based index in the accordion. |
Trigger
Button that opens and closes the panel. Renders a <button>. Sets aria-expanded and aria-controls. The plus icon rotates 45° when data-panel-open is set.
| Attribute | Description |
|---|---|
data-panel-open | Present when the panel is open. |
data-disabled | Present when the item is disabled. |
Panel
Collapsible region. Renders a <div role="region">. Height uses grid-template-rows: 0fr / 1fr with a short CSS transition (no animation library).
| Prop | Type | Default | Description |
|---|---|---|---|
hiddenUntilFound | boolean | false | Searchable closed panel for this item only. |
keepMounted | boolean | false | Keep this panel mounted while closed. Root keepMounted still applies. |
| Attribute | Description |
|---|---|
data-open | Present when the panel is open. |
data-disabled | Present when the item is disabled. |
data-index | Zero-based index in the accordion. |
data-orientation | Always vertical. |
data-starting-style | Present while the panel is animating in. |
data-ending-style | Present while the panel is animating out. |