Accordion / Collapsible
Expandable sections for FAQs and settings. These examples use the shipped VdAccordion component.
Multiple open panels
One open panel
- Shared colors and spacing follow the theme.
<script setup lang="ts">
import { ref } from "vue";
import { VdAccordion } from "@vanduo-oss/vd3";
const open = ref<string[]>([]);
const exclusiveOpen = ref("exclusive-tokens");
const items = [
{
id: "basic-tokens",
title: "Design tokens",
content: "Shared colors and spacing follow the theme.",
},
{
id: "basic-keyboard",
title: "Keyboard access",
content: "Tab to a header; Enter or Space toggles its panel.",
},
];
const exclusiveItems = items.map((item) => ({
...item,
id: item.id.replace("basic-", "exclusive-"),
}));
</script>
<template>
<div class="vd-row">
<div class="vd-col-12 vd-col-md-6">
<h6>Multiple open panels</h6>
<VdAccordion v-model="open" :items="items" />
</div>
<div class="vd-col-12 vd-col-md-6">
<h6>One open panel</h6>
<VdAccordion v-model="exclusiveOpen" :items="exclusiveItems" exclusive />
</div>
</div>
</template>
Component API
| Prop, event or slot | Behavior |
|---|---|
:items | Array of { id, title, content? }. Keep item IDs unique across the document. |
v-model | An array of open item IDs, or one ID when exclusive is true. |
:exclusive | Allow one open panel at a time. Default false. |
:animated | Enable smooth transitional height expansion with Fibonacci timing. Default true. |
@update:modelValue | Emits the new array or single ID; closing the exclusive panel emits an empty string. |
Named slots | A slot named after an item ID replaces its content and receives { item }. |
CSS collapsible
The stylesheet also ships .vd-collapsible for markup that is not the Vue component: .vd-collapsible-item, .vd-collapsible-header, .vd-collapsible-body, plus .vd-collapsible-bordered, .vd-collapsible-flush, .vd-collapsible-sm, and .vd-collapsible-lg.
Accessibility
Headers are native buttons with aria-expanded and aria-controls. Tab moves between headers; Enter or Space toggles a panel. Collapsed content is hidden. Use unique item IDs so controls reference the correct panel.