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.

This is the first item's accordion body. 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.

This is the second item's accordion body. 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.

This is the third item's accordion body. 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.
        
            
            <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.

Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.

Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.

Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
        
            
            <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.

This is the first item's accordion body. 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.

This is the second item's accordion body. 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.

This is the third item's accordion body. 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.
        
            
            <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.


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" />

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" />