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.

HTML

Press Enter to start editing
Unable to parse html
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. We polyfill a bug in Firefox when used with Android Talkback screen reader to announce state and role correctly.

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-border-block-wdithvar( --ds-border-width-default )
--dsc-details-border-block-widthvar(--dsc-details-border-block-wdith)
--dsc-details-border-block-stylesolid
--dsc-details-border-colorvar(--ds-color-border-subtle)
--dsc-details-icon-gapvar(--ds-size-2)
--dsc-details-icon-sizevar(--ds-size-6)
--dsc-details-icon-urlurl("data:image/svg+xml;charset=utf-8,%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-2) var(--ds-size-4)
--dsc-details-sizevar(--ds-size-14)
--dsc-details-backgroundvar(--ds-color-surface-default)
--dsc-details-summary-colorvar(--ds-color-text-default)
--dsc-details-summary-background--hovervar(--ds-color-surface-tinted)
--dsc-details-summary-background--openvar(--ds-color-surface-tinted)
--dsc-details-summary-backgroundvar(--ds-color-surface-default)
Data Attributes
NameValue
data-variantdefault, tinted

React

Controlled example

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

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)