Accordion
When to use
- A long page with self-contained sections that are read one at a time.
- An FAQ, settings or details, when closed blocks save vertical space.
- Comparing several sections at once — with
multiple.
When not to use
- For navigation between panels of one context, use
Tabs. - For mandatory steps of a process, use
Stepper. - Do not use it for a single permanent section: a plain heading is clearer.
Minimal example
<Accordion expandedKeys={expanded} onExpandedChange={setExpanded}>
<AccordionItem id="delivery" title="Delivery">
Delivery terms
</AccordionItem>
<AccordionItem id="payment" title="Payment">
Payment methods
</AccordionItem>
</Accordion>Public API
Accordion accepts multiple, className, children and the rest of react-aria's
DisclosureGroupProps, including controlled/uncontrolled keys. Do not
pass allowsMultipleExpanded: the component's public prop is multiple.
AccordionItem requires id and title; it also accepts disabled, className,
children. id is used in expandedKeys, so it must stay stable across re-renders.
Accessibility and keyboard
React Aria creates the trigger button, aria-expanded, the association with the panel, and hides
collapsed content from screen readers. The trigger sits inside a heading, so
a screen reader finds the section when navigating by heading. Do not render a second interactive control
in title; put it in the panel. See the
Accordion source.
Good examples
- The default
multiple={false}for sequential reading. multiplefor comparing specifications.- A disabled item instead of a section removed without explanation: it shows that the section is unavailable.
Anti-patterns
- Passing a plain
divinstead ofAccordionItem. - Using an unstable array index as
idin a mutable list. - Expanding all sections by default when they are not being compared.
Related sources and Storybook
src/components/navigation/Accordion.tsxsrc/components/navigation/Accordion.stories.tsx
TypeScript types
AccordionProps
Prop
Type
Plus DOM attributes, such as onClick, id, dir — 70 in total; the table does not repeat them.
AccordionItemProps
Prop
Type