- A-Z
- Accordion
- Acronym
- Action
- Alert
- Breadcrumbs
- Button
- Card
- Checkboxes
- Confirmation
- Cookie banner
- Copy
- Date input
- Details
- Env
- Error summary
- Filter
- Footer
- Forms
- Group
- Header
- Help
- Hero
- Hr
- Input
- Leave site
- Notification
- Pagination
- Panel
- Progress
- Radios
- Search input
- Select
- Signage
- Skip link
- Status
- Steps
- Summary list
- Table
- Tabs
- Textarea
- Time input
Your web browser is out of date
Your web browser (the software you use to access the internet) is out of date. You need to update it or use a different web browser to ensure you can complete this form.
Accordion
The accordion component lets users show and hide sections of related content on a page.
The component loads with all sections hidden. To show a section, the user can interact anywhere in the heading button.
<details class="asp-accordion">
<summary class="asp-accordion__summary">
<span class="asp-accordion__title">
<span class="asp-accordion__function">Accordion summary</span>
<span class="asp-accordion__chevron" aria-hidden="true">
<span class="asp-accordion__text--hide">Hide </span>
<span class="asp-accordion__text--show">Show </span>
</span>
</span>
</summary>
<div class="asp-accordion__content">
<p>Accordion content (html) with a <a href="#">link</a>.</p>
</div>
</details>
Nunjucks macro options
Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.
Some options are required for the macro to work; these are marked as "Required" in the option description.
If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.
| Name | Type | Description |
|---|---|---|
| summary | string | Required. The accordion summary text. |
| content | string | Required. The accordion component content. See content. |
Options for content
| Name | Type | Description |
|---|---|---|
| html | string | Required. HTML for the accordion component content. If 'html' is provided, the 'text' parameter will be ignored. |
| text | string | Required. Text for the accordion component content. If 'html' is provided, the 'text' parameter will be ignored. |
{% from "components/accordion/macro.njk" import aspAccordion %}
{{ aspAccordion({
summary: "Accordion summary",
content: {
html: "<p>Accordion content (html) with a <a href=</span>"#">link</a>.</p>"
}
}) }}
Twig macro options
Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.
Some options are required for the macro to work; these are marked as "Required" in the option description.
If you're using Nunjucks macros in production with "html" options, or ones ending with "html", you must sanitise the HTML to protect against cross-site scripting exploits.
| Name | Type | Description |
|---|---|---|
| summary | string | Required. The accordion summary text. |
| content | string | Required. The accordion component content. See content. |
Options for content
| Name | Type | Description |
|---|---|---|
| html | string | Required. HTML for the accordion component content. If 'html' is provided, the 'text' parameter will be ignored. |
| text | string | Required. Text for the accordion component content. If 'html' is provided, the 'text' parameter will be ignored. |
{% from "components/accordion/macro.njk" import aspAccordion %}
{{ aspAccordion({
summary: "Accordion summary",
content: {
html: "<p>Accordion content (html) with a <a href=</span>"#">link</a>.</p>"
}
}) }}
| Name | Type | Description |
|---|---|---|
| HeaderText | string | Required. This is a text input for the component header text shown. |
| BodyHTMLText | string | Required. This is a text input for the component body text shown when expanded. |
| BodyTextSize | number | Required. Number input for body text size. |
| DarkMode | boolean | Required. Input to determine if the component should be dark mode or not. Set by named formula variable varDarkMode. |
| TextBoxHeight | string |
Required.
This is an output property which is then used as the component Height property for example cmp_ASP_Accordian.TextBoxHeight.
|
When to use this component
Use an accordion to help users:
see an overview of multiple, related sections of content
choose to show and hide sections that are relevant to them
look across information that might otherwise be on different pages
For example, an accordion can work well if the user needs to reveal and compare information that’s relevant to them.
When not to use this component
Accordions hide content from the user. Not all users will notice them or understand how they work. For this reason, you should only use them in specific situations and if user research supports it.
Do not use an accordion for content that all users need to see.
Test your content without an accordion first. Well-written and structured content can remove the need to use an accordion.
It’s usually better to:
simplify and reduce the amount of content
keep the content on a single page, separated by headings
use a list of links at the start of the page (known as ‘anchor links’) to take the user to particular sections of a page
Accordions work best for simple content and links. Do not use accordions to split up a series of questions. Use separate pages instead.
Do not put accordions within accordions, as it will make content difficult to find.
Example of where we have used this component
This component is used on:
Public-facing website
Pocketbook
This list is not exhaustive.
Status of development
The below criteria all need to be met for a component to be considered as fully developed for use within the ASP Digital Design System.
| Development criteria | Status |
|---|---|
| WCAG 2.2 compliant | Not started |
| WCAG 2.1 compliant | Completed |
| HTML / Nunjucks version | Completed |
| Figma version | Not started |
| M365 versions | Not started |
| Documentation | In progress |
Make a change to the Design System
Suggest an edit to this system, or any of the components in it, by submitting a Design System change request.
Published 3 May 2024
Last updated 12 June 2026