Skip to content

GhostCollapsible ​

GhostCollapsible is an in-flow disclosure primitive: a trigger expands or collapses associated content following the WAI-ARIA APG Disclosure pattern. Import GhostCollapsible, GhostCollapsibleTrigger, and GhostCollapsibleContent from @ghostvue/themes for default trigger and panel styling, as every example on the ordinary path below does. For unstyled use from @ghostvue/vue, see Advanced: headless composition.

Release verification log ​

Release verification log

Controlled disclosure inside a release summary card with status badge and responsive rows.

Release v2.14.0 3 verification checks completed
Ready to promote
  • Unit & accessibility suite18s · Passed
  • Bundle size budget4s · Passed
  • Visual regression (Linux)42s · Passed

A controlled v-model:open disclosure toggles a verification checklist inside a GhostCard. The slot props expose { open } so the trigger label reflects the current state, and the rows adapt to the preview width with @container ghost-demo.

Show details in place ​

Shipment scan history

In-flow themed disclosure that reveals a carrier scan table and hides it after the close motion.

Order 48213 Out for delivery · 4 carrier scans
Delivery window: today, 2–6 PM.

Press Show scan history to reveal the carrier scans. The table opens in the page flow and pushes the delivery window below it down, rather than floating over it. The trigger keeps focus, aria-expanded follows the state, and the label switches between Show and Hide through the open slot prop.

Collapsing animates the panel's height first. The panel receives the native hidden attribute only when that motion finishes, or at once under prefers-reduced-motion: reduce. A test that checks the closed state should wait for hidden rather than assert it right after the click; in Playwright, await expect(panel).toBeHidden() retries until the transition ends. Set disableAnimation on GhostCollapsibleContent when the panel must hide immediately.

Inside a card or code block ​

Build steps in a card

Plain themed disclosure panel inside a build summary card, so the card draws the only frame.

Build #1482main · 4 steps · 1m 17s
Succeeded
  1. Install dependencies12s
  2. Type check21s
  3. Bundle client and server38s
  4. Upload to edge cache6s
Open the full log

The build card already draws a border and padding, so the panel sets variant="plain" on GhostCollapsibleContent. A plain panel has no border, corner radius, background, or inset padding of its own, and its content lines up with the rest of the card. Opening and closing animate the same way as the default framed panel, hidden is still applied after the close motion, and focus rings on controls at the panel's edge stay visible where the browser supports overflow-clip-margin. Keep the default variant="framed" when the panel sits on the page by itself.

Motion and reduced motion ​

Themed collapsible

Default surface styles with optional motion on expand.

Importing from @ghostvue/themes loads default.css, styling .ghost-collapsible-trigger and .ghost-collapsible-content with surface tokens. Optional height transitions respect prefers-reduced-motion; set disableAnimation on content to skip them entirely.

Accessibility ​

  • Disclosure semantics: no aria-haspopup, no focus move on toggle.
  • Collapsed content is hidden with the native hidden attribute.
  • Root and trigger disabled prevent activation.

Advanced: headless composition ​

Use this section when your team brings its own design system. Import the same parts from @ghostvue/vue; they keep the disclosure behavior and ARIA wiring and render no visual treatment.

Basic use ​

Collapsible disclosure Headless

Headless trigger and content linked with aria-controls.

GhostCollapsible owns open via useControllableState and assigns deterministic trigger/content ids via useGhostId. The content panel stays mounted and uses the native hidden attribute when collapsed.

API ​

See the generated component references for props, emits, slots, exposed members, styling hooks, CSS variables, and executable examples.

PropTypeDefaultDescription
defaultOpenbooleanfalseInitial open state when open is omitted.
disabledbooleanfalseDisables toggling on the trigger when true.
openboolean—Controlled open state. Omit for uncontrolled mode.
SlotSlot propsDescription
defaultopen: boolean, toggle: () => voidTrigger and content parts plus optional custom UI reading scoped state.

@ghostvue/themes adds no props, events, or slots to the headless GhostCollapsible API, which it forwards.

GhostCollapsible (root) ​

Emits update:open with (open: boolean). The default slot receives { open: boolean, toggle: () => void }.

GhostCollapsibleTrigger ​

Sets type="button" (when as="button"), aria-expanded, aria-controls, data-part="trigger", and data-state="open" | "closed". Exposes { element, focus, blur }.

GhostCollapsibleContent ​

Keeps the panel in the DOM with hidden when collapsed. Sets data-part="content", data-state, and aria-labelledby (pointing to the trigger unless aria-label or aria-labelledby is provided). Exposes { element, focus, blur }.

The themed panel adds variant. plain renders data-variant="plain"; the default framed renders no data-variant.

@ghostvue/themes adds these to the headless GhostCollapsibleContent API, which it forwards:

PropTypeDefaultDescription
variant'framed' | 'plain'"framed"Panel frame. framed draws the border, radius, and inset padding. plain draws none of them and no background, for a panel inside a surface that already frames it. Height motion and hidden timing are the same for both. The default omits data-variant.

Specification ​

See GhostCollapsible specification.