Accordion
Usage
Change labels
Change icons
To change icon for all items set icon
prop on Accordion component:
To change icon individually for each item, set icon
prop on Accordion.Item
component:
Change transition
To change transition duration, set transitionDuration
prop:
To disable transitions, set transitionDuration
to 0:
Customize styles
By default, Accordion has bare minimum styles to make customization simple, add additional styles with Styles API:
Control state
In most cases, Accordion can be uncontrolled, to change initial opened item use initialItem
prop:
In more advanced cases, Accordion state can be controlled with useAccordionState
hook:
Get control ref
Use controlRef
prop on Accordion.Item component to get control button ref:
Accessibility
Accordion component is accessible by default, it follows WAI ARIA guidelines:
- All controls are included in
Tab
sequence Up
andDown
arrows move focus to previous/next control- Item body has
role="region"
attribute - Item control has
aria-expanded
,aria-controls
,aria-labelledby
attributes - When user prefers to reduce motion,
transitionDuration
is automatically set to 0
To make the component visible for screen reader, include descriptive in Accordion.Item
label: