Skip to content
Mosaic
On this page

Collapsible

Headless, unstyled single panel shown and hidden by a button. Wires aria-expanded, aria-controls and role="region", and measures the panel so CSS can animate its size.

Use for

  • one section that shows and hides its content
  • a show more toggle or an advanced options panel

Practices

GuidancePractice
DoAnimate the panel size with --collapsible-panel-height and --collapsible-panel-width, set from the measured panel while it opens or closes.
Don’tPass id to the trigger or panel. The primitive owns both to pair them.
Don’tHide content by hand with display: none. The panel unmounts once closed.
Don’tStack several for a set of sections. Use Accordion instead.

API reference

Collapsible.Root

Holds the open state. Renders a div, or the render element, with data-open or data-closed, and data-disabled.

PropTypeDescription
openbooleanWhether the panel is open, when controlled.
defaultOpenbooleanWhether the panel is open on mount, when uncontrolled.Default: false
onOpenChange(open: boolean) => voidCalled with the new open state.
disabledbooleanStops the trigger from toggling.Default: false

Collapsible.Trigger

A button that toggles the panel. Carries aria-expanded, aria-controls, aria-disabled, and the same data attributes as the root.

Collapsible.Panel

The content, as role="region" labelled by the trigger. Carries data-open or data-closed. Unmounts once closed and its exit transition ends, and skips the enter transition on first mount.

Examples

A toggle

TSX
<Collapsible.Root>
  <Collapsible.Trigger>Advanced options</Collapsible.Trigger>
  <Collapsible.Panel>…</Collapsible.Panel>
</Collapsible.Root>