Skip to content

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

PropTypeDefaultDescription
disabledbooleanfalsePrevents the panel from being toggled.
unmountOnHidebooleanfalseRemove content from the DOM when closed.
asstring"div"Root element tag.
uiCollapsibleUi—CSS class overrides.

Slots

SlotScoped propsDescription
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

MethodSignatureDescription
open(reason?, event?) => voidOpens the panel.
close(reason?, event?) => voidCloses the panel.
toggle(reason?, event?) => voidToggles the panel.

Emits

EventPayloadDescription
open-change[open: boolean, details]Fired when the open state changes.

UI Options

KeyDescription
rootThe outer wrapper element.
triggerThe trigger element.
iconThe default icon element.
contentWrapperAnimated region wrapper.
contentInnerOverflow-hiding inner wrapper.
contentThe panel body element.

Styling Hooks

UI keyCSS classData attrs
rootakaza-collapsibledata-akaza-state, data-akaza-disabled
triggerakaza-collapsible-triggerdata-akaza-state, data-akaza-disabled
iconakaza-collapsible-icondata-akaza-state
contentWrapperakaza-collapsible-contentdata-akaza-state
contentInnerakaza-collapsible-content-inner—
contentakaza-collapsible-content-body—

Keyboard

KeyBehavior
Enter / SpaceToggles focused trigger through native button behavior.
Tab / Shift + TabUses native order. Closed content is inert and cannot receive focus.
Edit this page on GitHub ↗