Collapsible
Usage
Collapsible is an interactive container that expands and collapses related content behind a trigger. Use it when secondary content should stay out of the way until a user reveals it, composing mt-collapsible with mt-collapsible-trigger and mt-collapsible-content.
import {
MtCollapsible,
MtCollapsibleTrigger,
MtCollapsibleContent,
} from "@shopware-ag/meteor-component-library";
Examples
Disabled
Anatomy
Collapsible is built from three companion exports that work together:
mt-collapsibleis the root container that owns the open and closed state.mt-collapsible-triggeris the interactive element that toggles the open state. It renders as abuttonby default.mt-collapsible-contentis the region that is shown or hidden when the state changes.
API reference
Props
| Prop | Type | Default |
|---|---|---|
open | boolean | |
default-open | boolean | |
disabled | boolean | |
as | string | object | "div" |
as-child | boolean | false |
keep-mountedWhether the closed content stays mounted in the DOM when closed.
Defaults to `true` | boolean | true |
Events
| Event | Payload |
|---|---|
update:open | [value: boolean] |
Slots
| Slot | Bindings |
|---|---|
default | { open: boolean; } |
Behavior
- Collapsible is a compound pattern. You always compose
mt-collapsiblewithmt-collapsible-triggerandmt-collapsible-content. - The open state can be controlled externally with
v-model:openor left uncontrolled withdefault-open. - When
disabled, the trigger no longer toggles the content and the data attributes reflect the disabled state for styling. - The content slides open and closed over 300 ms by default, using the
--reka-collapsible-content-heightCSS variable that the component exposes on its content element. The animation respectsprefers-reduced-motion. keep-mounteddefaults totrueso the closed content stays in the DOM (it is hidden withhidden="until-found", which keeps it discoverable to the browser's find-in-page feature) and the slide animation can play. Setkeep-mounted="false"when the closed subtree is too expensive to leave mounted; the open and close animation will not play in that case.
Accessibility
- The trigger should always have a clear accessible name so users understand what content the toggle reveals.
- The trigger and content are linked through
aria-controlsandaria-expanded, so assistive technology announces the state change automatically. - When using a custom element via
as-child, make sure the rendered element is still focusable and supports keyboard activation.