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 "accordion/macro.njk" import aspAccordion %}

{{ aspAccordion({
summary: "Accordion summary",
content: {
html: '<p>Accordion content (html) with a <a href="#">link</a>.</p>' }
}) }}

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 Not started
Documentation In progress

Published 3 May 2024
Last updated 11 September 2024