Collapsible

A panel controlled by a button. There is no border. An open trigger rests on the wash, and hover and focus shift that wash. The trigger is rounded and Regular.

Anatomy

<UiCollapsibleRoot>
  <UiCollapsibleTrigger />
  <UiCollapsiblePanel />
</UiCollapsibleRoot>

Examples

Open

defaultOpen shows the panel on first render. Use open / @update:open for a controlled collapsible.

alien-bean-pasta
wild-irish-burrito
horse-battery-staple
<UiCollapsibleRoot :default-open="true">
  <UiCollapsibleTrigger>Recovery keys</UiCollapsibleTrigger>
  <UiCollapsiblePanel><!-- ... --></UiCollapsiblePanel>
</UiCollapsibleRoot>

Hidden until found

hiddenUntilFound hides the closed panel with hidden="until-found" so find-in-page (Ctrl+F / Cmd+F) can still search it and open the panel on a match. Closed content stays in the DOM, which also keeps it indexable. Search for “business days”.

<UiCollapsibleRoot hidden-until-found>
  <UiCollapsibleTrigger>Shipping details</UiCollapsibleTrigger>
  <UiCollapsiblePanel>
    Standard shipping takes 3–5 business days.
  </UiCollapsiblePanel>
</UiCollapsibleRoot>

Older browsers that don’t support hidden="until-found" keep the panel hidden until the trigger opens it.

Disabled

disabled ignores presses and sets data-disabled.

<UiCollapsibleRoot disabled>
  <UiCollapsibleTrigger>Recovery keys</UiCollapsibleTrigger>
  <UiCollapsiblePanel><!-- ... --></UiCollapsiblePanel>
</UiCollapsibleRoot>

API reference

Root

Groups all parts of the collapsible. Renders a <div>.

PropTypeDefaultDescription
defaultOpenbooleanfalseUncontrolled initial open state.
openboolean—Controlled open state (v-model:open).
disabledbooleanfalseIgnore interaction.
hiddenUntilFoundbooleanfalseApply hidden="until-found" to the closed panel. Overrides keepMounted.
keepMountedbooleanfalseKeep the panel in the DOM while closed. Ignored when hiddenUntilFound is set.
EventTypeDescription
@update:open(open: boolean) => voidEmitted when the panel opens or closes.
AttributeDescription
data-openPresent when the collapsible is open.
data-closedPresent when the collapsible is closed.
data-disabledPresent when the collapsible is disabled.
data-starting-stylePresent while the panel is animating in.
data-ending-stylePresent while the panel is animating out.

Trigger

A button that opens and closes the panel. Renders a <button> by default. Sets aria-expanded and aria-controls. The caret rotates 90° when data-panel-open is set.

PropTypeDefaultDescription
nativeButtonbooleantrueRender a native <button>. Set false to render a span with button semantics.
AttributeDescription
data-panel-openPresent when the panel is open.
data-disabledPresent when the collapsible is disabled.

Panel

The collapsible contents. Renders a <div role="region">. Height uses --collapsible-panel-height with a 150ms CSS transition (no animation library).

PropTypeDefaultDescription
hiddenUntilFoundbooleanfalseSearchable closed panel. Overrides keepMounted.
keepMountedbooleanfalseKeep this panel mounted while closed. Root keepMounted still applies.
AttributeDescription
data-openPresent when the panel is open.
data-closedPresent when the panel is closed.
data-starting-stylePresent while the panel is animating in.
data-ending-stylePresent while the panel is animating out.
CSS variableDescription
--collapsible-panel-heightThe panel’s height.
--collapsible-panel-widthThe panel’s width.