Skip to content

Accordion

Show related content in sections that expand and collapse.

Demos

Size
Type
Orientation
CollapsibleDisabledUnmount 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>

The open item can be closed again by default. Set :collapsible="false" when one selected item must remain open. Headers and content follow the selected size, and expansion respects reduced motion.

Appearance and sizing

A single rounded border contains the disclosure. Accordion items share full-width dividers. 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 Accordion.vue and index.ts into app/components/ui/accordion/.

API

Variants and defaults

PropValuesDefault
sizexs, sm, md, lg, xlsm

The preview controls size, selection type, keyboard orientation, collapsibility, disabled state, and content mounting. Open sections by clicking their headers; switching selection type resets the open value. Orientation changes the layout and arrow-key navigation. Horizontal sections appear side by side.

Props

PropTypeDefaultDescription
modelValuestring | string[]—Controlled open value through v-model; use an array for multiple mode.
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.
itemsAccordionItem[]—Required. List of accordion items.
type"single" | "multiple""single"Whether one or many items can be open simultaneously.
collapsiblebooleantrueAllow toggling the open item closed again (single mode only).
disabledbooleanfalseDisable all items.
orientation"vertical" | "horizontal""vertical"Orientation of the accordion.
unmountOnHidebooleanfalseRemove content from the DOM when closed instead of hiding it.
valueKeystring—Property to read as the unique item value.
labelKeystring"label"Property to use as the trigger label.
contentKeystring—Property to use as the body text.
disabledKeystring"disabled"Property to read for per-item disabled state.
asstring"div"Root element tag.
uiAccordionUi—CSS class overrides.

items and the key props describe your data. Use as, class, and ui in code to customize markup and styling.

Slots

SlotScoped propsDescription
trigger{ item, value, isOpen, toggle }Trigger button content for every item.
icon{ isOpen, item }Icon inside the trigger (e.g. chevron).
content{ item, value, isOpen }Panel body content for every item.
[item.slot]{ item, value, isOpen }Per-item panel override when item.slot is set.

Events

EventPayloadDescription
update:modelValue[value: string | string[]]Updates the controlled open value.
value-change[value: string | string[], details]Fired when the open item(s) change.

Keyboard

KeyBehavior
Enter / SpaceToggles focused trigger through native button behavior.
ArrowDown / ArrowUpMoves between enabled triggers in vertical orientation and loops.
ArrowRight / ArrowLeftMoves between enabled triggers in horizontal orientation and loops.
Home / EndFocuses first or last enabled trigger.