Accordion
Vue Accordion component
Responsive accordion built with the latest Bootstrap 5 and Vue 3. Accordion is a vertically collapsing element to show and hide content via class changes.
Build vertically collapsing accordions in combination with our Collapse JavaScript plugin.
How it works
The accordion uses collapse internally to make it collapsible.
Basic example
Click the accordions below to expand/collapse the accordion content.
MDBAccordionItem
, though the transition does limit overflow.
MDBAccordionItem
, though the transition does limit overflow.
MDBAccordionItem
, though the transition does limit overflow.
<template>
<MDBAccordion v-model="activeItem">
<MDBAccordionItem
headerTitle="Accordion Item #1"
collapseId="collapseOne"
>
<strong>This is the first item's accordion body.</strong> It is
shown by default, until the collapse plugin adds the appropriate
classes that we use to style each element. These classes control
the overall appearance, as well as the showing and hiding via
CSS transitions. You can modify any of this with custom CSS or
overriding our default variables. It's also worth noting that
just about any HTML can go within the
MDBAccordionItem, though the transition does limit
overflow.
</MDBAccordionItem>
<MDBAccordionItem
headerTitle="Accordion Item #2"
collapseId="collapseTwo"
>
<strong>This is the second item's accordion body.</strong>
It is hidden by default, until the collapse plugin adds the
appropriate classes that we use to style each element. These
classes control the overall appearance, as well as the showing
and hiding via CSS transitions. You can modify any of this with
custom CSS or overriding our default variables. It's also worth
noting that just about any HTML can go within the
MDBAccordionItem, though the transition does limit
overflow.
</MDBAccordionItem>
<MDBAccordionItem
headerTitle="Accordion Item #3"
collapseId="collapseThree"
>
<strong>This is the third item's accordion body.</strong> It is
hidden by default, until the collapse plugin adds the
appropriate classes that we use to style each element. These
classes control the overall appearance, as well as the showing
and hiding via CSS transitions. You can modify any of this with
custom CSS or overriding our default variables. It's also worth
noting that just about any HTML can go within the
MDBAccordionItem, though the transition does limit
overflow.
</MDBAccordionItem>
</MDBAccordion>
</template>
<script>
import { MDBAccordion, MDBAccordionItem } from "mdb-vue-ui-kit";
import { ref } from "vue";
export default {
components: {
MDBAccordion,
MDBAccordionItem
},
setup(){
const activeItem = ref('collapseOne');
return {
activeItem
}
}
};
</script>
Flush
Add flush
to remove the default background-color
, some
borders, and some rounded corners to render accordions edge-to-edge with their parent
container.
<template>
<MDBAccordion v-model="activeItem" flush>
<MDBAccordionItem
headerTitle="Accordion Item #1"
collapseId="flush-collapseOne"
>
<strong>This is the first item's accordion body.</strong> It is
shown by default, until the collapse plugin adds the appropriate
classes that we use to style each element. These classes control
the overall appearance, as well as the showing and hiding via
CSS transitions. You can modify any of this with custom CSS or
overriding our default variables. It's also worth noting that
just about any HTML can go within the
MDBAccordionItem, though the transition does limit
overflow.
</MDBAccordionItem>
<MDBAccordionItem
headerTitle="Accordion Item #2"
collapseId="flush-collapseTwo"
>
<strong>This is the second item's accordion body.</strong>
It is hidden by default, until the collapse plugin adds the
appropriate classes that we use to style each element. These
classes control the overall appearance, as well as the showing
and hiding via CSS transitions. You can modify any of this with
custom CSS or overriding our default variables. It's also worth
noting that just about any HTML can go within the
MDBAccordionItem, though the transition does limit
overflow.
</MDBAccordionItem>
<MDBAccordionItem
headerTitle="Accordion Item #3"
collapseId="flush-collapseThree"
>
<strong>This is the third item's accordion body.</strong> It is
hidden by default, until the collapse plugin adds the
appropriate classes that we use to style each element. These
classes control the overall appearance, as well as the showing
and hiding via CSS transitions. You can modify any of this with
custom CSS or overriding our default variables. It's also worth
noting that just about any HTML can go within the
MDBAccordionItem, though the transition does limit
overflow.
</MDBAccordionItem>
</MDBAccordion>
</template>
<script>
import { MDBAccordion, MDBAccordionItem } from "mdb-vue-ui-kit";
import { ref } from "vue";
export default {
components: {
MDBAccordion,
MDBAccordionItem
},
setup(){
const activeItem = ref('flush-collapseOne');
return {
activeItem
}
}
};
</script>
Always open
To make accordion items stay open when another item is opened add stayOpen
property to the MDBAccordion
component.
MDBAccordionItem
, though the transition does limit overflow.
MDBAccordionItem
, though the transition does limit overflow.
MDBAccordionItem
, though the transition does limit overflow.
<template>
<MDBAccordion v-model="activeItem" stayOpen>
<MDBAccordionItem
headerTitle="Accordion Item #1"
collapseId="stayOpen-collapseOne"
>
<strong>This is the first item's accordion body.</strong> It is
shown by default, until the collapse plugin adds the appropriate
classes that we use to style each element. These classes control
the overall appearance, as well as the showing and hiding via
CSS transitions. You can modify any of this with custom CSS or
overriding our default variables. It's also worth noting that
just about any HTML can go within the
MDBAccordionItem, though the transition does limit
overflow.
</MDBAccordionItem>
<MDBAccordionItem
headerTitle="Accordion Item #2"
collapseId="stayOpen-collapseTwo"
>
<strong>This is the second item's accordion body.</strong>
It is hidden by default, until the collapse plugin adds the
appropriate classes that we use to style each element. These
classes control the overall appearance, as well as the showing
and hiding via CSS transitions. You can modify any of this with
custom CSS or overriding our default variables. It's also worth
noting that just about any HTML can go within the
MDBAccordionItem, though the transition does limit
overflow.
</MDBAccordionItem>
<MDBAccordionItem
headerTitle="Accordion Item #3"
collapseId="stayOpen-collapseThree"
>
<strong>This is the third item's accordion body.</strong> It is
hidden by default, until the collapse plugin adds the
appropriate classes that we use to style each element. These
classes control the overall appearance, as well as the showing
and hiding via CSS transitions. You can modify any of this with
custom CSS or overriding our default variables. It's also worth
noting that just about any HTML can go within the
MDBAccordionItem, though the transition does limit
overflow.
</MDBAccordionItem>
</MDBAccordion>
</template>
<script>
import { MDBAccordion, MDBAccordionItem } from "mdb-vue-ui-kit";
import { ref } from "vue";
export default {
components: {
MDBAccordion,
MDBAccordionItem
},
setup(){
const activeItem = ref('stayOpen-collapseOne');
return {
activeItem
}
}
};
</script>
Accessibility
Please read the collapse accessibility section for more information.
If you want to support our friends from Tailwind Elements you can also check out the Tailwind Accordion documentation.
Accordion - API
Import
<script>
import {
MDBAccordion,
MDBAccordionItem
} from 'mdb-vue-ui-kit';
</script>
Properties
MDBAccordion
Name | Type | Default | Description |
---|---|---|---|
tag
|
String | 'div' |
Defines tag of the MDBAccordion element |
flush
|
Boolean | false |
Removes the default background-color, some borders, and some rounded corners from the accordion items |
stayOpen
|
Boolean | false |
Makes accordion items stay open when another item is opened |
classes
|
String |
|
Allows for custom classes for the element wrapper |
v-model
|
String |
|
Sets accordion item with given id active |
MDBAccordionItem
Name | Type | Default | Description | Example |
---|---|---|---|---|
tag
|
String | 'div' |
Defines tag of the MDBAccordionItem element |
|
collapseId
|
String |
|
Defines item id of the MDBAccordionItem element. Property is required |
|
headerTitle
|
String |
|
Defines header title of the element | |
headerClasses
|
String |
|
Allows for custom classes for the header title element | |
bodyClasses
|
String |
|
Allows for custom classes for the body element of the item | |
itemClasses
|
String |
|
Allows for custom classes for the item wrapper |
MDBAccordionHeader
Name | Type | Default | Description | Example |
---|---|---|---|---|
tag
|
String | 'div' |
Defines tag of the MDBAccordionHeader element |
<MDBAccordionHeader tag="section" />
|
bg
|
String |
|
Changes header's color |
<MDBAccordionHeader bg="primary" />
|
border
|
String |
|
Changes header's element border |
<MDBAccordionHeader border="warning" />
|
MDBAccordionTitle
Name | Type | Default | Description | Example |
---|---|---|---|---|
tag
|
String | 'h5' |
Defines tag of the MDBAccordionTitle element |
<MDBAccordionTitle tag="h6" />
|
subtitle
|
Boolean | false |
Changes component behavior to be rendered as subtitle with h6 tag
|
<MDBAccordionTitle subtitle />
|
MDBAccordionText
Name | Type | Default | Description | Example |
---|---|---|---|---|
tag
|
String | 'p' |
Defines tag of the MDBAccordionText element |
<MDBAccordionText tag="h1" />
|
MDBAccordionLink
Name | Type | Default | Description | Example |
---|---|---|---|---|
tag
|
String | 'a' |
Defines tag of the MDBAccordionLink element |
<MDBAccordionLink tag="h1" />
|
MDBAccordionImg
Name | Type | Default | Description | Example |
---|---|---|---|---|
tag
|
String | 'img' |
Defines tag of the MDBAccordionImg element |
<MDBAccordionImg tag="div" />
|
src
|
String |
|
Defines src attribute of the MDBAccordionImg element |
<MDBAccordionImg src="./some/path/here.webp" />
|
alt
|
String |
|
Defines alt attribute of the MDBAccordionImg element |
<MDBAccordionImg alt="image alt" />
|
top
|
Boolean | false |
Sets card image position at the top of the card |
<MDBAccordionImg top />
|
bottom
|
Boolean | false |
Sets card image position at the bottom of the card |
<MDBAccordionImg bottom />
|
fluid
|
Boolean | false |
Makes card image responsive |
<MDBAccordionImg fluid />
|
overlay
|
Boolean | false |
Turns image into a card background |
<MDBAccordionImg overlay> Accordion content </MDBAccordionImg>
|
MDBAccordionFooter
Name | Type | Default | Description | Example |
---|---|---|---|---|
tag
|
String | 'footer' |
Defines tag of the MDBAccordionFooter element |
<MDBAccordionFooter tag="section" />
|
bg
|
String |
|
Changes header's color |
<MDBAccordionFooter bg="primary" />
|
border
|
String |
|
Changes header's element border |
<MDBAccordionFooter border="warning" />
|
MDBAccordionGroup
Name | Type | Default | Description | Example |
---|---|---|---|---|
tag
|
String | 'div' |
Defines tag of the MDBAccordionGroup element |
<MDBAccordionGroup tag="section" />
|