react-accessible-accordion

Accessible Accordion component for React

npm badge Accessibility Status badge

React Accessible Accordion

React Component for creating an 'Accordion' that adheres to the WAI ARIA spec for accessibility.

Default behaviour

By default, only one item may be expanded and it can only be collapsed again by expanding another.

Expanding multiple items at once

If you set allowMultipleExpanded to true then the accordion will permit multiple items to be expanded at once.

Same as above except with allowMultipleExpanded=false

Collapsing the last expanded item

If you set allowZeroExpanded to true then a solitary expanded item may be collapsed again.

Pre-expanded items

If you set preExpanded, then you can choose which items are expanded on mount.

The strings passed to preExpanded are directly related to the uuid props of AccordionItem.

What harsh truths do you prefer to ignore?
In pariatur excepteur ut do aliquip qui mollit aliqua exercitation excepteur consequat reprehenderit nostrud laborum voluptate veniam non dolore dolore aliqua incididunt amet nisi minim cillum elit.

Informative onChange

When you use the onChange prop, you can get feedback about which items are expanded.

In this example, we are simply logging the uuids of the expanded items to the console. Have a click around then check your console to see this in action.

Accessing Item State

If you'd like to apply different content or styling based on the expanded or disabled state of an item, you might like to use the AccordionItemState render-prop component.

Manual state

When you use the dangerouslySetExpanded prop, you can manually override whether an AccordionItem is expanded.

Warning: This can impact accessibility negatively.

What harsh truths do you prefer to ignore?
In pariatur excepteur ut do aliquip qui mollit aliqua exercitation excepteur consequat reprehenderit nostrud laborum voluptate veniam non dolore dolore aliqua incididunt amet nisi minim cillum elit.
Is free will real or just an illusion?
Dolor esse proident nisi minim nisi aute nulla sed proident magna id eiusmod consectetur laborum aliqua minim excepteur sunt anim anim esse aliquip et ea enim proident veniam veniam quis adipisicing nulla amet id commodo.