Accordion
The accordion component is a stack of related sections, each of which people can expand to reveal its content or collapse to hide it.
Each section is made up of two parts:
- A trigger, which people can select to expand or collapse the section
- The expandable / collapsible area, with the section content
There are two variants:
- Default: The accordion lets each section expand and collapse independently. A "show/hide all sections" button at the top expands or collapses every section at once. If all sections are open, the button reads "hide all sections". If at least one section is closed, the button reads "show all sections".
- One at a time: The accordion can only have one section open at any given time. All sections can be closed, but opening a closed section will automatically close any open section. The first section is open when the page loads.
Example
What problems it solves
The accordion component helps reduce clutter on pages with a lot of related content. People can scan the section labels to find what they need, and expand only the sections that are relevant to them.
When to use it
Use the accordion component to reduce cognitive load when you have a lot of related content that people don't need to see all at once.
Use the default accordion when people may want to read or compare several sections, such as a list of frequently asked questions.
Use the one at a time variant when people are likely to only read one section at a time. This is similar to a tabs component.
Prefer the default accordion unless you have a reason not to. In the one at a time variant, collapsing a section that somebody did not ask you to collapse takes content away without warning, and it prevents people from being able to compare two sections side by side.
When not to use it
Do not use the accordion component for important information as some people may miss it.
Do not use it for a single section of content. Use the disclosure component instead.
Do not use it for content that most people need to read in full. Hiding it makes people do more work to reach it.
Where to use it
Accordions are often found in FAQs, product details, help pages, and long forms split into steps.
How it works
Each trigger is a button which describes its expanded or collapsed state.
The buttons and sections receive focus in the order they appear in the markup, and keyboard focus stays on the button after it is activated.
The default accordion has a "show all sections" button, which expands every section. It carries its own aria-expanded state like the rest of the buttons, but its label also changes to "Hide all sections". Arguably, because the label changes, it should not need to also use aria-expanded, but due to a VoiceOver bug, if you do not include it, then the label change is not always announced.
To make sure the state and the label never disagree, if some sections are open and others are closed, the button still reads "show all sections" with a collapsed state. Selecting it opens everything, changes the label to "hide all sections", and changes the state on the "show/hide all sections" button to expanded.
The button's collapsed label is set in the markup, and its expanded label is set using the data-hide-label attribute. Each is a whole phrase rather than a hard-coded "show/hide" prefix to make it compatible with localisation, because word order can differ between languages. If a page has more than one accordion, make each label specific, such as "show all frequently asked questions", so there is no confusion as to what each control does.
The one at a time variant has no "show all sections" button, because only one section can be open at a time. Activating the open section collapses it, which leaves every section closed.
Collapsed content is hidden using hidden="until-found", so anything focusable inside a collapsed section still revealed when using the browsers in-page search. Older browsers treat the attribute as plain hidden, so the content stays hidden until the button is used. See Hidden versus hidden until found in the compatibility notes for more information.
The content inside the collapsed section has an id, which can be targeted using a fragment in the URL. If the fragment is present on the URL, the disclosure will be open, so people can see the shared content when they arrive on the page.
When the page is printed, every section is shown expanded and the Show all sections button is left out.
Without JavaScript
Every section is progressively enhanced in the markup, so its content remains readable if the script does not run for some reason. Each trigger button is hidden on page load, but sits alongside a plain text placeholder with the same label. When the script runs, it collapses the content and swaps out the placeholder text for the buttons. This means all the content is available and no buttons are shown until it's all wired up to work.
Assistive technology compatibility
This component has been tested with the following browsers and assistive technologies.
| Assistive technology | Result | Notes |
|---|---|---|
| Keyboard | No issues | No notes |
| Voice Access/Chrome 154.0.8/Windows 11 | No issues | No notes |
| JAWS 2026.2603.86/Chrome 154.0.8/Windows 11 | No issues | No notes |
| NVDA 2026.1.1/Firefox 157.0/Windows 11 | No issues | No notes |
| VoiceOver/Safari macOS Tahoe 26.6 | No issues | No notes |
| VoiceOver/Safari/iOS 26.0 | No issues | Does not announce expanded or collapsed immediately after state change. This is a known bug with WebKit. See aria-expanded states are not announced immediately following a change on iOS in the compatibility notes. |
| TalkBack/Chrome 154.0.8/Android 17 | No issues | No notes |
| Windows Contrast themes | No issues | No notes |
| Windows Magnifier and/or Apple Zoom | No issues | No notes |
| Browser zoom | No issues | No notes |
| prefers-reduced-motion | Not applicable | There are no animations to reduce |
Last updated: 13 October 2026.