Details
<gcds-details>
Also called: accordion, collapse.
Details is an interactive switch for a person to expand or collapse content.
-
GitHub -
Figma
Details component preview
On this page
Coding and accessibility for details
Present the details component to support understanding
The details component can add to a person's cognitive load when it:
- Interrupts the flow of reading or scrolling.
- The content they need is difficult to find and search.
- They are unfamiliar with the expand and collapse function.
To help a reader's experience accessing details content:
- Use the
openattribute to define if the details content is open by default or not. - Make details titles clearly state what the content's about. Avoid non-descriptive titles such as "Read more". Instead, opt for a specific and descriptive summary, like "Maximum coverage amount for your physio benefit".
- Make titles distinct so people know the difference. Identical or similar titles can be confused.
- Avoid placing one details component inside another, where no one would know to look for that content.
- Make details content searchable.
In this section
details-title
The details-title attribute defines the label that summarizes the details content.
<gcds-details details-title="Learn more about this topic">
<gcds-text margin-bottom="0">Additional information.</gcds-text>
</gcds-details>
open
The open attribute controls whether the details component is open by default or not.
<gcds-details details-title="Learn more about this topic" open>
<gcds-text margin-bottom="0">Additional information.</gcds-text>
</gcds-details>
default
The default slot is for adding content inside the details component.
<gcds-details details-title="Learn more about this topic">
<gcds-text margin-bottom="0">Additional information.</gcds-text>
</gcds-details>
Code builder
Generate an instance of the component you need by selecting its code properties.
-
Explore by choosing different code values to generate the instance you want.
-
Get the code and pull it into your environment.
-
Add any copy you need to the component (like text for a label).
Note: The code builder uses English for all code elements, which follows standard practice.
Help us improve
Have questions or a request? Give feedback on our contact form.
Something's wrong? Raise it through GitHub with an