Components
Accordion
- Overview
- Usage
Overview
Accordions vs Tabs
If you decide to use one of these components, consider if:
- the user needs to look at more than one section at a time – an accordion can show multiple sections at a time, unlike tabs
- the user needs to switch quickly between sections – tabs can show content without pushing other sections down the page, unlike accordions
- there are many sections of content – accordions can fit more sections as they’re arranged vertically, unlike tabs which are arranged horizontally.
Principles
An accordion will usually start with all sections hidden. To show a section, the user can interact anywhere in the heading area.
Write the title like any other button text. Use sentence case, describe the content that will show, and keep it short. Users of screen readers might find it difficult to navigate the accordion if the title is too long.
Do not auto-close or auto-open accordions an do not auto-scroll the opened accordion to the top of the screen.
Suffix
Usage guidelines
Expand icon
Use the ‘chevron-down’ icon when the accordion is collapsed and the ‘chevron-up’ icon when it's expanded. Do not switch the icons and do not replace them with other icons.
Nesting
Do not nest accordions within accordions, as it will make content difficult to find.
Titles
The title should be as brief as possible while still being clear and descriptive.
Scrolling
When the accordion content is longer than the viewport the whole accordion should vertically scroll with the rest of the page. Content should not scroll inside of an individual panel and content should never scroll horizontally in an accordion.