Skip to main content

Accordion

The Accordion list a vertically stacked list of headers that reveal or hide associated sections of content.

Overview

Definition

  • An accordion is a vertically stacked list of headers that reveal or hide associated sections of content.
  • It is used to put long sections of information under a block that users can expand or collapse.
  • Accordions decrease cognitive load by letting people choose which sections of content they see, like questions in an FAQ.

Common usage

When to use

  1. To organize related information into sections.
  2. To shorten pages and reduce scrolling when content is not crucial to read in full.
  3. When space is at a premium and long content cannot be displayed all at once, like on a mobile interface or in a side panel.
  4. To prioritize essential information while still providing access to additional details for those who need it.

When not to use

  • Displaying links pointing to sections of the same page.
  • Never put information that's required for the current task inside an accordion. Consider a treatment that gives it more prominence.
  • If a user is expected to read all of the content.

General guidance

Accessibility guidance

Enable keyboard interactions with accordion:

  • tab to switch between accordion items
  • When the accordion item is in focus, space or enter to expand or collapse the accordion item
  • Interactive elements (such as a link or button) within an expanded accordion item integrate into the tab order by default

Content guidance

  • Title should be as brief as possible
  • If title is too long it can be wrapped to the next line
  • Content inside of a section may be split into paragraphs

Accordion vs Stepper

  • To guide users through a process use a Stepper instead.

Accordion vs Expandable section

If the information inside each section is not related to each other but can be accessed by users who want more context or clarification. (e.g. unrelated sections on order details page such as Account details, Shipping details etc.).

Main rules

  • Follow the QDS hierarchical structure for embedded content.
  • Use accordion types for specific hierarchy levels.
  • Accordion width may vary and depends on the place where it's used

Accordion Item

Accordion Item is a component that must be a direct child of the Accordion component. You can include as many Accordion Items as you like and specify the necessary properties for each one.

Properties

is-open

If this property is set to true, the Accordion Item will be open by default.

Loading...
Live Editor
<qds-web-accordion layer="main" level="section">
  <qds-web-accordion-item text="This is a main section accordion">
    Incididunt Lorem ea commodo veniam. Id velit labore qui laboris enim aliquip
    enim ipsum nulla. Tempor ullamco duis excepteur qui labore quis culpa labore
    minim ex dolor ad. Aliqua pariatur anim fugiat nulla non. Labore labore esse
    enim quis reprehenderit exercitation consectetur occaecat. Non mollit dolor
    et exercitation ipsum. Occaecat do aute elit non ut sit irure sunt esse.
  </qds-web-accordion-item>
  <qds-web-accordion-item
    is-open="true"
    text="This is a main section accordion"
  >
    Incididunt Lorem ea commodo veniam. Id velit labore qui laboris enim aliquip
    enim ipsum nulla. Tempor ullamco duis excepteur qui labore quis culpa labore
    minim ex dolor ad. Aliqua pariatur anim fugiat nulla non. Labore labore esse
    enim quis reprehenderit exercitation consectetur occaecat. Non mollit dolor
    et exercitation ipsum. Occaecat do aute elit non ut sit irure sunt esse.
  </qds-web-accordion-item>
</qds-web-accordion>

text

The text which will show as the accordion item title

divider

Control whether to display the bottom divider line or not, which can be useful when using the accordion in the filtering panel use case.

Loading...
Live Editor
<qds-web-accordion layer="main" level="section">
  <qds-web-accordion-item
    divider="false"
    text="This is a main section accordion"
  >
    Incididunt Lorem ea commodo veniam. Id velit labore qui laboris enim aliquip
    enim ipsum nulla. Tempor ullamco duis excepteur qui labore quis culpa labore
    minim ex dolor ad. Aliqua pariatur anim fugiat nulla non. Labore labore esse
    enim quis reprehenderit exercitation consectetur occaecat. Non mollit dolor
    et exercitation ipsum. Occaecat do aute elit non ut sit irure sunt esse.
  </qds-web-accordion-item>
  <qds-web-accordion-item
    divider="false"
    text="This is a main section accordion"
  >
    Incididunt Lorem ea commodo veniam. Id velit labore qui laboris enim aliquip
    enim ipsum nulla. Tempor ullamco duis excepteur qui labore quis culpa labore
    minim ex dolor ad. Aliqua pariatur anim fugiat nulla non. Labore labore esse
    enim quis reprehenderit exercitation consectetur occaecat. Non mollit dolor
    et exercitation ipsum. Occaecat do aute elit non ut sit irure sunt esse.
  </qds-web-accordion-item>
</qds-web-accordion>

Layer and level

The layer and level properties set the [layer][] and [level][] to which the accordion belongs. By default, the layer property is set to main and the level property is set to section

Loading...
Live Editor
<qds-web-accordion>
  <qds-web-accordion-item text="This is a main section accordion">
    Incididunt Lorem ea commodo veniam. Id velit labore qui laboris enim aliquip
    enim ipsum nulla. Tempor ullamco duis excepteur qui labore quis culpa labore
    minim ex dolor ad. Aliqua pariatur anim fugiat nulla non. Labore labore esse
    enim quis reprehenderit exercitation consectetur occaecat. Non mollit dolor
    et exercitation ipsum. Occaecat do aute elit non ut sit irure sunt esse.
  </qds-web-accordion-item>
</qds-web-accordion>

The accordion component is designed for two levels:

  1. section
  2. subsection

Depending on your content hierarchy, accordion can be used for Main, Panel and Popup layers

Loading...
Live Editor
<qds-web-accordion layer="panel" level="subsection">
  <qds-web-accordion-item text="This is a panel subsection accordion">
    Incididunt Lorem ea commodo veniam. Id velit labore qui laboris enim aliquip
    enim ipsum nulla. Tempor ullamco duis excepteur qui labore quis culpa labore
    minim ex dolor ad. Aliqua pariatur anim fugiat nulla non. Labore labore esse
    enim quis reprehenderit exercitation consectetur occaecat. Non mollit dolor
    et exercitation ipsum. Occaecat do aute elit non ut sit irure sunt esse.
  </qds-web-accordion-item>
</qds-web-accordion>
Loading...
Live Editor
<qds-web-accordion layer="popup" level="section">
  <qds-web-accordion-item text="This is a popup section accordion">
    Incididunt Lorem ea commodo veniam. Id velit labore qui laboris enim aliquip
    enim ipsum nulla. Tempor ullamco duis excepteur qui labore quis culpa labore
    minim ex dolor ad. Aliqua pariatur anim fugiat nulla non. Labore labore esse
    enim quis reprehenderit exercitation consectetur occaecat. Non mollit dolor
    et exercitation ipsum. Occaecat do aute elit non ut sit irure sunt esse.
  </qds-web-accordion-item>
</qds-web-accordion>