Skip to content

Accordion

<details class="asp-accordion">
  <summary class="asp-accordion__summary">
    <span class="asp-accordion__title">
      <svg class="asp-accordion__icon" aria-hidden="true" focusable="false" viewBox="0 0 10 10">
        <rect class="asp-accordion__icon-vertical" height="8" width="2" y="1" x="4"></rect>
        <rect height="2" width="8" y="4" x="1"></rect>
      </svg>
      Accordion summary
    </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="#">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 "asp-frontend/components/accordion/macro.njk" import aspAccordion %}

{{ aspAccordion({
summary: "Accordion summary",
content: {
html: '<p>Accordion content (html) with a <a href="#">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

‘Accordion’ allow us to hide content until the user interacts with the element, at which point content is shown in a drop down.

This element can be used to break up long pages of content, using clear headers to help the user navigate.

Future considerations

Remove SVG from inline -- either background CSS or ::before or ::after pseudo

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 Completed
Documentation In progress

Published 3 May 2024
Last updated 6 February 2025