This is the first item's accordion body. It is shown by default, until the collapse
plugin adds the appropriate classes that we use to style each element. These classes control the overall
appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with
custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go
within the .accordion-body, though the transition does limit overflow.
This is the second item's accordion body. It is hidden by default, until the collapse
plugin adds the appropriate classes that we use to style each element. These classes control the overall
appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with
custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go
within the .accordion-body, though the transition does limit overflow.
This is the third item's accordion body. It is hidden by default, until the collapse
plugin adds the appropriate classes that we use to style each element. These classes control the overall
appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with
custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go
within the .accordion-body, though the transition does limit overflow.
Text: Serves to tell users what the accordion is being used for.
Container: Encloses the content within, width and height to be adjusted according to content.
Open
Text: Serves to tell users what the accordion is being used for. Bold when the accordion
is open.
Container: Encloses the content within, width and height to be adjusted according to
content.
Content: Content should be kept as short and to the point as possible to help with
scanning.
Spacing
Within the accordion button
Ensure that there is a min of 24px horizontal spacing and 16px vertical spacing.
Within the accordion
Ensure that there is a min of 24px spacing within the accordion, and 16px vertical spacing
between the accordion title and content.
Usage guidelines
Best practices:
Accordion labels should not link to a page; labels and buttons should open the same thing. (e.g. your label should not link to another page, and your icon opens the accordion).
Accordion should be used when:
There is insufficient space within the page to display the necessary information.
Users require an overview of specific content that's related to one another.
Accordion should not be used when:
Each section only contains a small amount of text or a few elements, an accordion can unnecessarily complicate the layout. Simple lists or headings might work better.
User needs to see all information in a single page.
The user wants to compare information in a single layout.
Usability guidelines
Do ensure that the entire heading is clickable to the user
A larger target will make it easier for users to manipulate.
Ensure enough space between content and headings
This is to prevent the user from accidentally closing the accordion.
Behaviour
In addition to the collapse and expanded states, accordions should also have interactive state for focus. User should be able to trigger a state change by clicking anywhere in the header area.
Accessibility guidelines
Aria attributes
The accordion header has a role of <button>, with an aria-expanded attribute set to "true" or "false".
The button has an aria-controls property set to the unique id of the panel it controls.
Keyboard accessibility
Ensure that the accordion can be navigated and operated using the keyboard:
Tab or Shift-Tab to navigate between accordion headers.
Enter or Space to expand or collapse sections.
Focus indicator
Focus indicator should be clearly visible when a header is focused.
Move focus to the accordion content when it is expanded, if necessary.
Ensure that focusable elements within the accordion panel can be navigated using the keyboard.