Disclosure

Disclosure

Show/hide content with a toggle button.

Based on APG Disclosure Pattern.

Demo

This is the disclosed content. It can contain any HTML elements including text, images, forms, or other components. The panel smoothly animates open and closed.

Usage

let expanded = @resource.signal(false)

@styled_disclosure.disclosure(
  "details",
  expanded,
  "Show details",
  [@luna.text("Hidden content goes here...")],
)

Props

PropTypeDefaultDescription
idString-Base ID for disclosure
expandedSignal[Bool]-Expanded state
trigger_textString-Button text
childrenArray[Node]-Content to show/hide
classString?NoneAdditional CSS class

BEM Classes

ClassDescription
.disclosureRoot container
.disclosure__triggerToggle button
.disclosure__iconExpand/collapse icon
.disclosure__panelContent panel
.disclosure__contentInner content wrapper

States

StateDescription
data-state="open"Content visible
data-state="closed"Content hidden

Keyboard

KeyAction
Enter/SpaceToggle visibility