Skip to content

Collapsible

Show or hide a single section of content.

Demos

Size
DisabledUnmount on hide

Usage

vue
<script setup lang="ts">
import { Accordion } from '~/components/ui/accordion'

const items = [
  { value: 'source', label: 'Do I own the source?', content: 'Yes. Copy and adapt the files.' },
]
</script>

<template>
  <Accordion :items="items" />
</template>

Use the content slot for the expandable body. Header height, icon, text, radius, and body padding follow the selected size. Expansion respects reduced motion.

Appearance and sizing

A single rounded border contains the disclosure. It uses the same header and body spacing as Accordion. The open header has a light tint, and body text aligns with its label. Focus stays inside the outer border.

SizeHeader heightHorizontal paddingTextIcon
xs40px12px12px12px
sm44px16px13px14px
md48px20px14px16px
lg52px24px14px18px
xl56px28px16px20px

These headers have 16px more height than compact controls to support longer labels and the expanded body. Coarse-pointer targets stay at least 44px tall.

Installation

Complete the shared installation. Copy Collapsible.vue and index.ts into app/components/ui/collapsible/.

API

Variants and defaults

PropValuesDefault
sizexs, sm, md, lg, xlsm

Props

PropTypeDefaultDescription
modelValuebooleanfalseControlled open state through v-model.
size"xs" | "sm" | "md" | "lg" | "xl""sm"Coordinated header and content sizing. Shared UI configuration can override the default.
classHTMLAttributes['class']—Classes merged into the root recipe.
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.

Events

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

Exposed methods

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

Keyboard

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