Accordion
import { Accordion } from '@bbc/front-end-kit/vue'
A collapsible content component that can be used to show and hide the content it contains.
Getting started
<template>
<Accordion v-model:is-open="isOpen" @toggle="onToggle">
<template #header>
<!-- Accordion header here -->
</template>
<template #content>
<!-- Accordion content here -->
</template>
</Accordion>
</template>
<script setup>
import { ref, watch } from 'vue'
import { Accordion } from '@bbc/front-end-kit/vue'
const isOpen = ref(false)
// toggle listener
function onToggle({ isOpen }) {
console.log('Accordion is now', isOpen ? 'open' : 'closed')
}
// watcher for the open state
watch(isOpen, (isOpen) => {
console.log('Accordion is now', isOpen ? 'open' : 'closed')
})
</script>
API
Properties
Icon
The icon component rendered inside the toggle. The icon rotates 180° when the accordion opens.
Values: Vue Component
Default: IconChevronDown
iconProps
Object with attributes/props forwarded to the icon component via v-bind.
Values: Object
Default: {}
Models
isOpen
V-model for the accordion's open state. Toggling the header updates this value; updating it externally plays/reverses the open animation.
Type: Boolean
Default: false
Events
toggle
Emitted whenever isOpen changes (via header click or external update).
Payload: { isOpen: Boolean }
Slots
header
The header area of the accordion. Receives clicks to toggle.
content
The collapsible content body.