Skip to main content

Components

Details

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

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
any
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

childrenany-

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

DetailsSummary

children
Description

Heading text

Type
any
NameTypeDefaultDescription
childrenany-

Heading text

Usage

Examples

Frame and variant

If you put Details as the only child of Card, you get a frame around the whole Details. You can also use variant="tinted" on either Details or Card to get a lighter background.

Controlled

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

HTML

Details is built on the web component u-details (github.io), which you can use. It is built functionally similar to the native element <details>, but with better accessibility.

You use the class name .ds-details on the main element.

You can choose not to have a nested <div> around the main content, but if you have this, it gets margin.

If you want to use tinted variant, add the attribute data-variant="tinted" to the main element or .ds-card.

CSS variables and data attributes

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
Edit this page on github.com (opens in a new tab)