Demos

The first marker is always visible. The trigger shows the rest.

Usage

Use a collapsible for one block of secondary content, like extra rows in a list. For several sections in a stack, use an Accordion.

Import it from @workspace/ui/components/collapsible.

Anatomy

  • Collapsible — Holds the open state.
  • CollapsibleTrigger — The control that toggles the content.
  • CollapsibleContent — The content that shows and hides.

Notes

  • The component has no styles of its own. Style the trigger and content for the context.
  • Pass a button through render on the trigger to reuse the Button styles.
  • An icon-only trigger needs an aria-label.

Examples

Controlled

Hold the state with open and onOpenChange to change the trigger label.

Props

These are the props you set most often. Unlisted props pass through to the underlying element.

Collapsible

PropTypeDefaultDescription
defaultOpenbooleanfalseOpen on first render.
openboolean—Open state when controlled.
onOpenChange(open) => void—Called when the state changes.
disabledbooleanfalseStops the trigger from toggling.

CollapsibleTrigger

PropTypeDefaultDescription
renderReactElement—Element to render instead of a button.