Accordions are a list of headers that can be clicked to hide or reveal additional content.
data-multiselectable attribute allows multiple accordions in a set to be open at the same time. This attribute can applied to any style of accordion.
When to use accordions
- Users only need a few specific pieces of content within a page.
- Information needs to be displayed in a small space.
When to consider something else
- If visitors need to see most or all of the information on a page. Use well-formatted text instead.
- If there is not enough content to warrant condensing. Accordions increase cognitive load and interaction cost, as users have to make decisions about what headers to click on.
How to use accordions
- Allow users to click anywhere in the header area to expand or collapse the content; a larger target is easier to manipulate.
- Make sure interactive elements within the collapsible region are far enough from the headers that users don’t accidentally trigger a collapse. (The exact distance depends on the device.)
- Keep accordion content succinct. Accordion height will fluctuate depending on the content. If the accordion has subheading, we do not recommend the subheading to wrap to 2 lines.
- Code header areas in the accordion as
<buttons>so that they are usable with both screen readers and the keyboard.
- Buttons should state if they are expanded with
- Each button has a unique name
aria-controls="id"that associates the control to the appropriate region by referencing the controlled element’s
- Each content area will have its
aria-hidden="true"on any of your content areas.