Olddevs UI4.14.0
Navigation

Accordion

Publishing runs on weekdays at 9:00 AM and 6:00 PM.

Up to 3 collections and 100 documents.

Unlimited collections, shared workspaces and version history.

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.
  • multiple for comparing specifications.
  • A disabled item instead of a section removed without explanation: it shows that the section is unavailable.

Anti-patterns

  • Passing a plain div instead of AccordionItem.
  • Using an unstable array index as id in a mutable list.
  • Expanding all sections by default when they are not being compared.
  • src/components/navigation/Accordion.tsx
  • src/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

On this page