- Unit & accessibility suite
- Bundle size budget
- Visual regression (Linux)
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
Controlled disclosure inside a release summary card with status badge and responsive rows.
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
In-flow themed disclosure that reveals a carrier scan table and hides it after the close motion.
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
Plain themed disclosure panel inside a build summary card, so the card draws the only frame.
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
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
hiddenattribute. - Root and trigger
disabledprevent 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
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.
| Prop | Type | Default | Description |
|---|---|---|---|
defaultOpen | boolean | false | Initial open state when open is omitted. |
disabled | boolean | false | Disables toggling on the trigger when true. |
open | boolean | — | Controlled open state. Omit for uncontrolled mode. |
| Slot | Slot props | Description |
|---|---|---|
default | open: boolean, toggle: () => void | Trigger 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:
| Prop | Type | Default | Description |
|---|---|---|---|
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. |