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.

Press Enter to start editing
<details class="ds-details">
  <summary>Who can register in the Volunteer Register?</summary>
  <div>
    To be registered in the Volunteer Register, the organization must
    conduct voluntary activities. Only associations, foundations, and
    limited companies can be registered. The business cannot distribute
    funds to individuals. The business must have a board.
  </div>
</details>
const PreviewEn = () => {
  return (
    <Details>
      <Details.Summary>
        Who can register in the Volunteer Register?
      </Details.Summary>
      <Details.Content>
        To be registered in the Volunteer Register, the organization must
        conduct voluntary activities. Only associations, foundations, and
        limited companies can be registered. The business cannot distribute
        funds to individuals. The business must have a board.
      </Details.Content>
    </Details>
  );
};

render(<PreviewEn />)

Usage

Details is a native <details> element.

With frame

If you want a frame around details, you can put it in a ds-card.

CSS variables and data attributes

Sizes are controlled with data-size and colors with data-color. The component will inherit from the closest parent where these are set.

CSS Variables
NameValue
--dsc-details-backgroundvar(--ds-color-surface-default)
--dsc-details-border-block-stylesolid
--dsc-details-border-block-wdithvar( --ds-border-width-default )
--dsc-details-border-block-widthvar(--dsc-details-border-block-wdith)
--dsc-details-border-colorvar(--ds-color-border-subtle)
--dsc-details-icon-gapvar(--ds-size-2)
--dsc-details-icon-sizevar(--ds-icon-size)
--dsc-details-icon-urlurl("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5.97 9.47a.75.75 0 0 1 1.06 0L12 14.44l4.97-4.97a.75.75 0 1 1 1.06 1.06l-5.5 5.5a.75.75 0 0 1-1.06 0l-5.5-5.5a.75.75 0 0 1 0-1.06'/%3E%3C/svg%3E")
--dsc-details-paddingvar(--ds-size-4)
--dsc-details-sizevar(--ds-size-14)
--dsc-details-summary-backgroundvar(--ds-color-surface-default)
--dsc-details-summary-background--hovervar(--ds-color-surface-tinted)
--dsc-details-summary-background--openvar(--ds-color-surface-tinted)
--dsc-details-summary-colorvar(--ds-color-text-default)
Data Attributes
NameValue
data-variantdefault, tinted

Polyfill

We use @u-elements/u-details/polyfill to fix missing accessibility state announcement in <summary> in Firefox with Android TalkBack screen reader.

React

Controlled example

Details keeps track of whether it is open or closed, but this can also be controlled externally.

Details

variant
Description

Change the background color of the details.

Type
"default" | "tinted"
Default
'default'
open
Description

Controls open-state. Using this removes automatic control of open-state

Type
boolean
Default
undefined
defaultOpen
Description

Defaults the details to open if not controlled

Type
boolean
Default
false
onToggle
Description

Callback function when Details toggles due to click on summary or find in page-search

Type
(((event: Event) => void) & ((event: Event) => void)) | (((event: Event) => void) & ((event: Event) => void))
children
Description

Content should be one `<Details.Summary>` and `<Details.Content>`

Type
ReactNode
NameTypeDefaultDescription
variant"default" | "tinted"'default'

Change the background color of the details.

openbooleanundefined

Controls open-state. Using this removes automatic control of open-state

defaultOpenbooleanfalse

Defaults the details to open if not controlled

onToggle(((event: Event) => void) & ((event: Event) => void)) | (((event: Event) => void) & ((event: Event) => void))-

Callback function when Details toggles due to click on summary or find in page-search

childrenReactNode-

Content should be one `<Details.Summary>` and `<Details.Content>`

DetailsSummary

children
Description

Heading text

Type
ReactNode
NameTypeDefaultDescription
childrenReactNode-

Heading text

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