Skip to main content
U.S. flag

An official website of the United States government

Dot gov

The .gov means it’s official.
Federal government websites often end in .gov or .mil. Before sharing sensitive information, make sure you’re on a federal government site.

Https

The site is secure.
The https:// ensures that you are connecting to the official website and that any information you provide is encrypted and transmitted securely.

Components

Accordion

Use: Best practice English, Spanish
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.

Examples

Default

View va-accordion in Storybook

Bordered

View va-accordion in Storybook

Single Select

  • Adding an open-single prop on the va-accordion component will allow the user to only open one accordion at a time.

View va-accordion in Storybook

Subheader

View va-accordion in Storybook

Usage

When to use accordions

  • Organizing related sections of content to condense and chunk the content. When you need to organize related sections of content into a smaller space use accordions to condense and group the content.
  • A series of content: If you have a series of content in the body of a page and outside of a form or tool. For example, if you have a series of questions as part of an FAQ section or a set of options for payment that each have additional details.
  • Reveal and compare relevant information. When users need to reveal and compare relevant and related information accordions can make this easier.

When to consider something else

  • Users need to see most or all of the information on the page at one time. Use well-formatted text with descriptive 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 Additional info component instead to leverage show/hide functionality, especially in a form.
  • Required content: If the majority of people need the content to accomplish the main task then it should not be hidden from view.

Behavior

  • 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.)

Code usage

Attributes and Properties

Property Attribute Type Default Description
bordered bordered boolean false Whether or not the accordion items will have borders
disableAnalytics disable-analytics boolean false If `true`, doesn't fire the CustomEvent which can be used for analytics tracking.
openSingle open-single boolean false True if only a single item can be opened at once
sectionHeading section-heading string null Optional accordion section heading text. Only used in analytics event. Default is null.

Events

Name Description
component-library-analytics The event used to track usage of the component. This is emitted when an accordion item is toggled and disableAnalytics is not true.
accordionItemToggled This event is fired when an accordion item is opened or closed

Content considerations

  • 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.

Accessibility considerations

  • 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 aria-expanded="true". The aria-expanded="false" attributes will be added to other buttons when the accordion is initialized by the JavaScript.
  • Each button has a unique name aria-controls="id" that associates the control to the appropriate region by referencing the controlled element’s id.
  • Each content area will have its aria-hidden attribute set to either true or false by the component, depending on its corresponding button’s aria-expanded attribute. To ensure that your content is accessible in the event that the JavaScript does not load or is disabled, you should not set aria-hidden="true" on any of your content areas.
  • Testing: the spacebar or enter key must be able to toggle the expand/collapse state of the panel.
Edit this page in GitHub (Permissions required)
Last updated: Aug 25, 2022