Accordion
Coordinate one or several expandable sections with shared disclosure rules.
Anatomy#
Usage#
Use Accordion for several related disclosures that share one open-item policy. For a single independent disclosure, use Collapsible.
Content#
content accepts text or JSX, or a component that receives { value, expanded, disabled }.
Use the component form when the panel depends on the item state. Content mounts on first open. headingLevel (default 3) sets the heading level that
wraps each trigger. icon adds a leading icon to an item, and expandIcon replaces the indicator icon
for every item.
Open items#
value, defaultValue, and onValueChange always use an array of item values. By default, opening an
item closes the others. Set multiple to allow several open items. Pair value with onValueChange
when the page owns the open set. onValueChange receives the complete next array and fires only for
user toggles, not for changes you make to value. In single mode, collapsible (default true)
controls whether the open item can close; with multiple, every item can always close.
Content lifetime#
The content shell always stays mounted, so each trigger’s aria-controls points to a real element.
forceMount controls only the content inside that shell. By default, content mounts on first open and
unmounts when it closes. Set forceMount to mount content before the first open and keep it mounted, so
hidden fields preserve local state.
Keyboard interaction#
| Key | Description |
|---|---|
| ↵ / Space | Toggles the focused trigger when enabled. |
| ↓ | Moves focus to the next enabled trigger. |
| ↑ | Moves focus to the previous enabled trigger. |
| ↖ | Moves focus to the first enabled trigger. |
| ↘ | Moves focus to the last enabled trigger. |
Arrow-key focus wraps from the last trigger to the first by default. Set loop={false} to stop at
either end. Disabled items are skipped.
Examples#
Answer a workspace FAQ#
Keep one section open at a time. Read value when surrounding copy needs to name the active topic.
Configure several workspace sections#
Set multiple when operators need billing, security, and general settings open together.
Complete a setup checklist with a locked step#
Use item disabled for sections the current plan cannot open. Put lists or callouts in content
when the answer is more than a paragraph.
Keep draft notes while a section closes#
Set forceMount so inputs inside a panel keep their values across toggles.
Drive the open FAQ from page state#
Pair value with onValueChange. The array always holds item values, even in single mode. Surrounding
copy can read the same signal to name the active topic.
API Reference#
Attributes#
data-disableddata-closeddata-expandedProps#
Props for the Accordion component. Renders a <div> element by default.