VAccordion

The VAccordion component provides an easy way to create collapsible content panels, allowing users to expand and collapse sections as needed. This component is built with accessibility in mind and can be easily customized to suit your design requirements.

Usage

To use the VAccordion component, simply wrap your VAccordionItem components within a VAccordion parent component:

The Catcher in the Rye is a classic novel by J.D. Salinger, published in 1951. It tells the story of Holden Caulfield, a disenchanted and rebellious teenager who wanders around New York City after being expelled from his prep school. The novel explores themes such as teenage angst, alienation, and the loss of innocence. Over the years, it has become a defining work of American literature and has influenced generations of readers.
Example.vue
<template>
<VAccordion v-model:activeIndex="activeIndex">
<VAccordionItem header="A Brief History of Time">
A Brief History of Time, written by the famous physicist Stephen Hawking, ...
</VAccordionItem>
<VAccordionItem header="The Catcher in the Rye">
The Catcher in the Rye is a classic novel by J.D. Salinger, published ...
</VAccordionItem>
</VAccordion>
</template>
<script lang="ts" setup>
const activeIndex = ref(1);
</script>

Active Index

The activeIndex prop can be either a number representing the index of a single VAccordionItem or an array of numbers for multiple active items. The index refers to the order in which the VAccordionItem components are inserted.

By default, only one VAccordionItem can be expanded at a time. To allow multiple expanded items, set the multiple prop to true.

The Catcher in the Rye is a classic novel by J.D. Salinger, published in 1951. It tells the story of Holden Caulfield, a disenchanted and rebellious teenager who wanders around New York City after being expelled from his prep school. The novel explores themes such as teenage angst, alienation, and the loss of innocence. Over the years, it has become a defining work of American literature and has influenced generations of readers.
Example.vue
<template>
<VAccordion v-model:activeIndex="activeIndex" multiple>
<VAccordionItem header="A Brief History of Time">
A Brief History of Time, written by the famous physicist Stephen Hawking, ...
</VAccordionItem>
<VAccordionItem header="The Catcher in the Rye">
The Catcher in the Rye is a classic novel by J.D. Salinger, published ...
</VAccordionItem>
</VAccordion>
</template>
<script lang="ts" setup>
const activeIndex = ref([1]);
</script>

Props

PropTypeDefaultDescription
activeIndexString, Number, ArraynullThe active index or indices of the expanded AccordionItems. Can be a single number for a single expanded item or an array of numbers for multiple expanded items.
multipleBooleanfalseDetermines whether multiple AccordionItems can be expanded at the same time. If set to true, the activeIndex prop will accept an array of indices.