Skip to content
🌏 Translated with the assistance of DeepSeek and ChatGPT

Collapse ​

The Collapse component is used to group content into collapsible panels.

Basic Usage ​

By default, each panel can be independently expanded / collapsed.

Use the active prop together with the update:active event for controlled mode, where the parent component manages the active panels. When active is not passed or is undefined, the component operates in uncontrolled mode. Use default-active to set the initially expanded panels.

Controlled Panel 1

This panel is controlled via the active prop.

Controlled Panel 2
Controlled Panel 3
Hide source code

Accordion Mode ​

When the accordion prop is set, only one panel can be open at a time. Clicking an already open panel will close it.

Panel 1
Panel 2
Panel 3
Hide source code

Variants ​

The variant prop supports three styles: 'line', 'card' (default), and 'none'.

Panel 1
Panel 2
Hide source code

Expand Icon ​

Use expand-icon-placement to control the arrow position ('left' / 'right'). Use show-expand-icon to show or hide the arrow.

Left Arrow (Default)
Right Arrow
No Arrow
Hide source code

Disabled State ​

Set the disabled prop on px-collapse-item to disable a panel, preventing it from being expanded or collapsed.

Active Panel
Disabled Panel
Another Active Panel
Hide source code

Custom Slots ​

px-collapse-item provides title, prefix, and suffix slots for customizing the header area.

Custom Title Slot
🔔
With Prefix & Suffix
⭐
New
Hide source code

API ​

CollapseProps ​

AttributeTypeOptionalDefaultDescriptionVersion
active(string | number | symbol)[]TrueArray of currently active panel indices (controlled mode).0.2.0
defaultActive(string | number | symbol)[]TrueDefault active panel indices (uncontrolled mode).0.2.0
variant'none' | 'card' | 'line'True'card'Visual variant.0.2.0
accordionbooleanTruefalseWhether to enable accordion mode.0.2.0
showExpandIconbooleanTruetrueWhether to show the expand arrow.0.2.0
expandIconPlacement'left' | 'right'True'left'Expand arrow placement.0.2.0
animationDurationnumberTrue250Animation duration in milliseconds.0.2.0
destroyOnHidebooleanTruefalseWhether to destroy content DOM when collapsed.0.2.0
disabledbooleanTruefalseWhether to disable all panels.0.2.0
pollSizeChangebooleanTruefalseWhether to poll for container size changes.0.2.0

CollapseEvents ​

EventParameterDescriptionVersion
update:activeactiveIndices: (string | number | symbol)[]Emitted when active state changes in controlled mode, payload is the active indices array.0.2.0
changeactiveIndices: (string | number | symbol)[]Emitted when active state changes, payload is the active indices array.0.2.0

CollapseSlots ​

SlotParameterDescriptionVersion
defaultDefault slot for placing CollapseItem components.0.2.0

CollapseItemProps ​

AttributeTypeOptionalDefaultDescriptionVersion
indexstring | number | symbolFalseUnique identifier for the panel.0.2.0
titlestringTruePanel title text.0.2.0
disabledbooleanTruefalseWhether to disable the panel.0.2.0
destroyOnHidebooleanTruefalseIndividually control whether to destroy content DOM when collapsed.0.2.0

CollapseItemSlots ​

SlotParameterDescriptionVersion
defaultPanel content.0.2.0
titleCustom title area.0.2.0
prefixContent before the title.0.2.0
suffixContent after the title.0.2.0