Collapsible
A single section that can be expanded or collapsed.
Collapsible controls one expandable region, such as a filter panel, "show more" section, or code block.
For a list of collapsible items with headings, see Accordion.
Anatomy
#trigger: Content rendered inside the trigger button.#icon: Optional indicator rendered after the trigger content.#content: Panel revealed when open.
The trigger button is rendered by the component. Use the ui.trigger prop to add classes to it.
Usage
Examples
With animated icon
The #trigger slot renders inside the trigger button. Use ui.trigger to style the button and #icon to replace the default chevron.
vue
import './main.css'
Programmatic control
Use exposed methods when another control needs to open or close the panel.
vue
<template>
<Accordion
:items="items"
type="multiple"
/>
</template>
Unmount on hide
Remove the content from the DOM when collapsed, instead of hiding it.
vue
<Dialog
:ui="{
overlay: 'fixed inset-0 bg-black/50',
content: 'fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 rounded-lg bg-white p-6',
}"
/>
API Reference
Props
| Prop | Type | Default | Description |
|---|---|---|---|
disabled | boolean | false | Prevents the panel from being toggled. |
unmountOnHide | boolean | false | Remove content from the DOM when closed. |
as | string | "div" | Root element tag. |
ui | CollapsibleUi | — | CSS class overrides. |
Slots
| Slot | Scoped props | Description |
|---|---|---|
trigger | { isOpen, open, close, toggle } | The toggle trigger element. |
icon | { isOpen } | Indicator icon inside the trigger. |
content | { isOpen, close } | The collapsible panel body. |
Exposed methods
| Method | Signature | Description |
|---|---|---|
open | (reason?, event?) => void | Opens the panel. |
close | (reason?, event?) => void | Closes the panel. |
toggle | (reason?, event?) => void | Toggles the panel. |
Emits
| Event | Payload | Description |
|---|---|---|
open-change | [open: boolean, details] | Fired when the open state changes. |
UI Options
| Key | Description |
|---|---|
root | The outer wrapper element. |
trigger | The trigger element. |
icon | The default icon element. |
contentWrapper | Animated region wrapper. |
contentInner | Overflow-hiding inner wrapper. |
content | The panel body element. |
Styling Hooks
| UI key | CSS class | Data attrs |
|---|---|---|
root | akaza-collapsible | data-akaza-state, data-akaza-disabled |
trigger | akaza-collapsible-trigger | data-akaza-state, data-akaza-disabled |
icon | akaza-collapsible-icon | data-akaza-state |
contentWrapper | akaza-collapsible-content | data-akaza-state |
contentInner | akaza-collapsible-content-inner | — |
content | akaza-collapsible-content-body | — |
Keyboard
| Key | Behavior |
|---|---|
Enter / Space | Toggles focused trigger through native button behavior. |
Tab / Shift + Tab | Uses native order. Closed content is inert and cannot receive focus. |