Accordions, which use the UX principle of progressive disclosure, are a list of headers that can be clicked to hide or reveal additional content. By default, accordions are multi-selectable and borderless, however, props can be added to make them bordered and single-select.
- Adding an
open-singleprop on the
va-accordioncomponent will allow the user to only open one accordion at a time.
When to use accordions
Use an accordion:
- When users only need to access a few pieces of related information within a content-heavy page.
- To organize related content in a small space.
When to consider something else
Consider another solution if:
- Users need to see most or all of the information on the page at one time. Use well-formatted text with discriptive headings instead.
- There is not enough content to warrant condensing. Accordions increase cognitive load and interaction cost, as users have to make decisions about which headers to click.
- Users would benefit from seeing additional context for a discrete piece of content. Use the Addtional info component instead to leverage show/hide functionality.
See Expandable content for more accordion usage guidelines.
- 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 (such as links) within the collapsible region are far enough from the header that users don’t accidentally trigger a collapse. (The exact distance will depend on the device.)
- Keep content succinct – accordion height will fluctuate depending on the length of the content.
- If the accordion has a subheading, it should not wrap to two lines.
- In general, accordions should organize static content. Outside of the forms review page, where accordions are used to group sections of editable information, we discourage the use of form elements like radio buttons, checkboxes, and buttons within accordions. Interactive elements will not be focusable when the accordion is in a collapsed state.
- Code header areas in the accordion as
<buttons>so that they are usable with both screen readers and the keyboard.
- The spacebar or enter key must be able to toggle the expand/collapse state of the panel.
- 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.