KANTO DS v1.12.0
Customise

Theme

Accent

Font

Corners

Density

Text size

Reset to Kanto
Overlays

kt-collapsible

GitHub Copy link

A section that folds away.

Preview

Email me about mentions Email me a weekly digest
Two-factor authentication is enabled.

A section that folds away.

<kt-collapsible heading="Notifications" open> <kt-toggle checked>Email me about mentions</kt-toggle> <kt-toggle>Email me a weekly digest</kt-toggle> </kt-collapsible>

Built on <details>

Which buys three things for free:

  • It works before the JavaScript loads — the browser opens and closes it on its own.
  • Find-in-page opens it. A browser will expand a closed <details> to reveal a match inside it; a div with a click handler hides that text forever.
  • It needs no ARIA of its own. <summary> is already a button with the right expanded state.

The default disclosure triangle is replaced with a chevron that rotates, which is the only cosmetic liberty taken.

API

PropertyAttributeTypeDefault
openopenbooleanfalse
headingheadingstring''
plainplainbooleanfalse

plain drops the bottom rule, for a collapsible that is not one of a stacked list.

SlotDescription
defaultThe contents
summaryReplaces the heading attribute
EventDetail
kt-toggle{ open: boolean }
PartDescription
baseThe <details>
summaryThe clickable row
contentThe revealed panel