2.7.0
Accordions expand and collapse content below a Header to control the display of a cohesive set of information and functionality.
That combination of options is invalid.
Accordions are constructed using the Headers component, see the Headers page for all available variations. Use the content container to hold any other components or product markup.
Name
|
Required
|
Description
|
---|---|---|
Header |
Yes |
Offers a title summarizing the content and affords functionality via optional actions. See Headers for all available variations. |
Arrow |
Yes |
Acts as an affordance to indicate the functionality of the accordion, as well as a visual marker of the state of the accordion through its rotation and direction. |
Content |
Yes |
Holds other components or product markup and is visually shown and hidden by interacting with the header. |
Use to provide expand and collapse functionality for a section of content.
[Your content here.]
[Your content here.]
<div class="mds-accordion">
<input id="label-header--11955" type="checkbox" role="button" aria-controls="mds-accordion-example--11955" class="mds-accordion__trigger" />
<label for="label-header--11955" class="mds-accordion__label">
<div class="mds-header mds-header--primary mds-header--level-5">
<h2 class="mds-header__title">
Accordion Title
<div class="mds-header__title-description">
<button class="mds-button mds-button--icon-only" type="button">
<svg class="mds-icon mds-button__icon mds-button__icon--left" aria-hidden="true">
<use xlink:href="#question-circle">
</use>
</svg>
</button>
</div>
</h2>
<div class="mds-header__actions">
<button class="mds-button mds-button--secondary" type="button">
Action
</button>
</div>
</div>
</label>
<section class="mds-accordion__content" id="mds-accordion-example--11955">
<p>[Your content here.]</p>
</section>
</div>
Use when omitting the contained Header’s border.
[Your content here.]
[Your content here.]
<div class="mds-accordion">
<input id="label-header--82033" type="checkbox" role="button" aria-controls="mds-accordion-example--82033" class="mds-accordion__trigger" />
<label for="label-header--82033" class="mds-accordion__label">
<div class="mds-header mds-header--level-5">
<h2 class="mds-header__title">
Accordion Title
<div class="mds-header__title-description">
<button class="mds-button mds-button--icon-only" type="button">
<svg class="mds-icon mds-button__icon mds-button__icon--left" aria-hidden="true">
<use xlink:href="#question-circle">
</use>
</svg>
</button>
</div>
</h2>
<div class="mds-header__actions">
<button class="mds-button mds-button--secondary" type="button">
Action
</button>
</div>
</div>
</label>
<section class="mds-accordion__content" id="mds-accordion-example--82033">
<p>[Your content here.]</p>
</section>
</div>
Use when placing an accordion within a Module Container.
[Your content here.]
[Your content here.]
<div class="mds-accordion doc-accordion-bottom-border">
<input id="label-header--37352" type="checkbox" role="button" aria-controls="mds-accordion-example--37352" class="mds-accordion__trigger" />
<label for="label-header--37352" class="mds-accordion__label">
<div class="mds-header mds-header--primary mds-header--level-5 mds-header--border-bottom">
<h2 class="mds-header__title">
Accordion Title
<div class="mds-header__title-description">
<button class="mds-button mds-button--icon-only" type="button">
<svg class="mds-icon mds-button__icon mds-button__icon--left" aria-hidden="true">
<use xlink:href="#question-circle">
</use>
</svg>
</button>
</div>
</h2>
<div class="mds-header__actions">
<button class="mds-button mds-button--secondary" type="button">
Action
</button>
</div>
</div>
</label>
<section class="mds-accordion__content" id="mds-accordion-example--37352">
<p>[Your content here.]</p>
</section>
</div>
mds-header--border-bottom
modifier class on the Header within this variation.Follow the Headers sizing guidelines. An accordion’s arrow element will resize automatically to visually match the mds-header--level-[1–9]
modifier class applied to the contained Header.
This example shows an accordion placed within a Module Container and includes attributes establishing an accessible relationship between the two components.
mds-header--border-bottom
modifier class to restyle the header's border and internal padding for placement within a container.To meet accessibility requirements, some additional attributes must be added to the markup to establish a relationship between the Header and Module Container.
id
to the mds-header__title
element.id
in an aria-labelledby
attribute on the mds-module-container
element.The Morningstar Design System aligns product teams on Morningstar brand, visual language, UX, and technical standards.
<div class="mds-module-container" aria-labelledby="header-id-1">
<div class="mds-accordion">
<input id="label-header--93344" type="checkbox" role="button" aria-controls="mds-accordion-example--0003" class="mds-accordion__trigger" />
<label for="label-header--93344" class="mds-accordion__label">
<div class="mds-header mds-header--primary mds-header--level-5 mds-header--border-bottom">
<h2 class="mds-header__title" id="header-id-1"> Accordion Title 1 </h2>
<div class="mds-header__actions">
<button class="mds-button mds-button--secondary" type="button"> Action </button>
</div>
</div>
</label>
<section class="mds-accordion__content" id="mds-accordion-example--0003">
<div class="accordion-sample-paragraph">
<p>The Morningstar Design System aligns product teams on Morningstar brand, visual language, UX, and technical standards.</p>
</div>
</section>
</div>
</div>
This example shows a stack of accordions with stack space constants used to apply margin-bottom
to each.
To space out accordions vertically, apply stack space constants within your product’s code. For instance, this example:
<div>
using the demo-accordion--stack
class..demo-accordion--stack {
.mds-accordion {
margin: $mds-space-stack-2-x;
&:last-child {
margin: 0;
}
}
}
The Morningstar Design System aligns product teams on Morningstar brand, visual language, UX, and technical standards.
The Morningstar Design System aligns product teams on Morningstar brand, visual language, UX, and technical standards.
The Morningstar Design System aligns product teams on Morningstar brand, visual language, UX, and technical standards.
<div class="demo-accordion--stack">
<div class="mds-accordion">
<input id="label-header--9191" type="checkbox" role="button" aria-controls="mds-accordion-example--9191" class="mds-accordion__trigger" />
<label for="label-header--9191" class="mds-accordion__label">
<div class="mds-header mds-header--primary mds-header--level-5">
<h2 class="mds-header__title">
Accordion Title 1
</h2>
<div class="mds-header__actions">
<button class="mds-button mds-button--secondary" type="button">
Action
</button>
</div>
</div>
</label>
<section class="mds-accordion__content" id="mds-accordion-example--9191">
<div class="accordion-sample-paragraph">
<p>The Morningstar Design System aligns product teams on Morningstar brand, visual language, UX, and technical standards.</p>
</div>
</section>
</div>
<div class="mds-accordion">
<input id="label-header--66283" type="checkbox" role="button" aria-controls="mds-accordion-example--66283" class="mds-accordion__trigger" />
<label for="label-header--66283" class="mds-accordion__label">
<div class="mds-header mds-header--primary mds-header--level-5">
<h2 class="mds-header__title">
Accordion Title 2
</h2>
<div class="mds-header__actions">
<button class="mds-button mds-button--secondary" type="button">
Action
</button>
</div>
</div>
</label>
<section class="mds-accordion__content" id="mds-accordion-example--66283">
<div class="accordion-sample-paragraph">
<p>The Morningstar Design System aligns product teams on Morningstar brand, visual language, UX, and technical standards.</p>
</div>
</section>
</div>
<div class="mds-accordion">
<input id="label-header--81861" type="checkbox" role="button" aria-controls="mds-accordion-example--81861" class="mds-accordion__trigger" />
<label for="label-header--81861" class="mds-accordion__label">
<div class="mds-header mds-header--primary mds-header--level-5">
<h2 class="mds-header__title">
Accordion Title 3
</h2>
<div class="mds-header__actions">
<button class="mds-button mds-button--secondary" type="button">
Action
</button>
</div>
</div>
</label>
<section class="mds-accordion__content" id="mds-accordion-example--81861">
<div class="accordion-sample-paragraph">
<p>The Morningstar Design System aligns product teams on Morningstar brand, visual language, UX, and technical standards.</p>
</div>
</section>
</div>
</div>
margin-bottom
to the block element.mds-accordion__content
element a unique id
and set it as the mds-accordion__trigger
element’s aria-controls
attribute. For example:<input id="label-header--7410" type="checkbox" role="button" aria-controls="mds-accordion-example--0001" class="mds-accordion__trigger">
...
<section class="mds-accordion__content" id="mds-accordion-example--0001">
...
aria-expanded
attribute on the mds-accordion__trigger
element and write custom JavaScript to toggle its boolean value based on whether the accordion is expanded or collapsed. For example:<!-- Collapsed State -->
<input id="label-header--7410" type="checkbox" role="button" aria-expanded="false" aria-controls="mds-accordion-example--0002" class="mds-accordion__trigger">...
<!-- Expanded State -->
<input id="label-header--7410" type="checkbox" role="button" aria-expanded="true" aria-controls="mds-accordion-example--0002" class="mds-accordion__trigger">...