Accordion
stableA vertically stacked set of interactive headings that each reveal a section of content.
Basic usage
Examples
Multiple panels
Allow several panels to be open simultaneously.
Multiple open panels
Use type="multiple" for FAQ and settings pages where several sections can stay open.
Invoices, payment methods and tax details.
Two-factor authentication and audit logs.
Features
- Full keyboard navigation.
- Supports single or multiple expanded panels.
- Can be controlled or uncontrolled.
- Spring-eased height animation.
Installation
bash
pnpm dlx structyl add accordionAPI Reference
Accordion.Root
Contains all accordion items.
| Prop | Type | Default |
|---|---|---|
| type | 'single' | 'multiple'Whether one or many panels can be open. | — |
| value | string | string[]Controlled open item(s). | — |
| defaultValue | string | string[]Initial open item(s). | — |
| onValueChange | (value) => voidCalled when the open set changes. | — |
| collapsible | booleanFor type='single', allow closing the open item. | false |
| disabled | booleanDisable the whole accordion. | false |
Accordion.Item
A single collapsible section.
| Prop | Type | Default |
|---|---|---|
| value | stringUnique value identifying the item. | — |
| disabled | booleanDisable this item. | false |
Accordion.Trigger
Toggles its panel. Wrapped in a Header.
| Prop | Type | Default |
|---|
Accordion.Content
The collapsible panel content.
| Prop | Type | Default |
|---|---|---|
| forceMount | booleanForce mounting for animation control. | — |
Keyboard interactions
Adheres to the WAI-ARIA design pattern .
| Key | Description |
|---|---|
| Space / Enter | Expands / collapses the focused panel. |
| ArrowDown / ArrowUp | Moves focus between headers. |
| Home / End | Moves focus to the first / last header. |