If you answer yes, we store and analyse information that helps us improve the website. You can change your choice at any time at the bottom of the page. More about what we store and why.

We also store necessary information that cannot be opted out of. This makes the website work and keeps it secure.

Skip to main content

What are you looking for?

Try searching for…

Components

Details

Details is a collapsible component that allows the user to show or hide content.

Use details when

  • it should be up to the user whether they choose to read the content
  • you want to give examples or answer frequently asked questions
  • you need to split up content to avoid too much information at once

Avoid details when

  • you need to show important content that everyone should see
  • you need to summarise error messages, use error summary instead

Details is the same as what many know as an accordion. The name comes from the built-in HTML element <details>, which provides good accessibility and semantics without additional JavaScript.

Example

You can use details inside a card to give the content a frame. This works well when details does not cover the whole page, or when it is only one row.

Guidelines

Large amounts of text can be demanding for many users. Details allows users to decide for themselves what is relevant to read. However, you should not use details to hide content just to make the page look tidier. When content is hidden, there is a risk that users will not notice it at all. Carefully consider whether the content really needs to be hidden, and be clear about why you are doing so.

Avoid details inside details

It can be confusing for users to understand what is open and closed, especially when several levels can be opened at the same time.

Avoid closing other details when one details is opened

This can cause users to lose content they want to compare or return to. Only do this when it is clear to the user that only one details can be open at a time, and this behaviour is expected.

Text

Make sure the heading clearly describes what the content in details is. Headings can have a large impact on whether users find what they need, whether the content is read, and whether it can be considered accessible to all users. "Show more" or "Read more here" are not good enough titles. If you have details with many expandable sections, you can add a main heading or theme heading above the whole list.

Keep the content inside details short so it is easy to relate to the heading. If the content is too long, divide it into several details. For very large amounts of content, it may be better to create separate pages.

Edit this page on github.com (opens in a new tab)