Accordion

Build vertically collapsing accordions in combination with BCollapse component.

How it works

The BAccordionItem uses the BCollapse component internally to make it collapsible. To render an accordion that’s expanded, add the visible property on the BAccordionItem component.

Example

Click the accordions below to expand/collapse the accordion content.

HTML
template
<BAccordion>
  <BAccordionItem title="Accordion Item #1" visible>
    <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 is also worth
    noting that just about any HTML can go within the <code>.accordion-body</code>, though the
    transition does limit overflow.
  </BAccordionItem>
  <BAccordionItem title="Accordion Item #2">
    <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 is also worth
    noting that just about any HTML can go within the <code>.accordion-body</code>, though the
    transition does limit overflow.
  </BAccordionItem>
  <BAccordionItem title="Accordion Item #3">
    <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 is also worth
    noting that just about any HTML can go within the <code>.accordion-body</code>, though the
    transition does limit overflow.
  </BAccordionItem>
</BAccordion>

Flush

Add flush property to remove the default background-color, some borders, and some rounded corners to render accordions edge-to-edge with their parent container.

HTML
template
<BAccordion flush>
  <BAccordionItem title="Accordion Item #1">
    Placeholder content for this accordion, which is intended to demonstrate the
    <code>flush</code> property. This is the first item's accordion body.
  </BAccordionItem>
  <BAccordionItem title="Accordion Item #2">
    Placeholder content for this accordion, which is intended to demonstrate the
    <code>flush</code> property. This is the second item's accordion body. Let's imagine this
    being filled with some actual content.
  </BAccordionItem>
  <BAccordionItem title="Accordion Item #3">
    Placeholder content for this accordion, which is intended to demonstrate the
    <code>flush</code> property. This is the third item's accordion body. Nothing more exciting
    happening here in terms of content, but just filling up the space to make it look, at least at
    first glance, a bit more representative of how this would look in a real-world application.
  </BAccordionItem>
</BAccordion>

Always open

Add free property to make accordion items stay open when another item is opened.

HTML
template
<BAccordion free>
  <BAccordionItem title="Accordion Item #1">
    <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 is also worth
    noting that just about any HTML can go within the <code>default</code> slot, though the
    transition does limit overflow.
  </BAccordionItem>
  <BAccordionItem title="Accordion Item #2">
    <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 is also worth
    noting that just about any HTML can go within the <code>default</code> slot, though the
    transition does limit overflow.
  </BAccordionItem>
  <BAccordionItem title="Accordion Item #3">
    <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 is also worth
    noting that just about any HTML can go within the <code>default</code> slot, though the
    transition does limit overflow.
  </BAccordionItem>
</BAccordion>

Component Reference

<BAccordion>
PropTypeDefaultDescription
flushbooleanfalse Remove the default background-color, some borders, and some rounded corners to render accordions edge-to-edge with their parent container
freebooleanfalse Accordion items will stay open when another item is opened
idstringundefined The Id to be injected to accordion items and used in BCollapse for state managment
initial-animationbooleanfalse When set, enables the initial animation on mount
lazybooleanfalse When set, the content will not be mounted until opened
model-valuebooleanfalse Controls the visibility of the component
unmount-lazybooleanfalse When set and `lazy` is true, the content will be unmounted when closed
EventArgsDescription
update:model-value
value: string - Id of the accordion item that is open
Update the currently opened accordion item
NameScopeDescription
defaultContent to place in the Accordion
<BAccordionItem>
PropTypeDefaultDescription
body-attrsReadonly<AttrsValue>undefined Attributes to be applied to the body of the accordion item
body-classClassValueundefined Class to be applied to the body of the accordion item
button-attrsReadonly<AttrsValue>undefined Attributes to be applied to the button in header
button-classClassValueundefined Class to be applied to the button in header
collapse-classClassValueundefined Class to be applied to the collapse
header-attrsReadonly<AttrsValue>undefined Attributes to be applied to the header element
header-classClassValueundefined Class to be applied to the header element
header-tagstring'h2' Tag to be used for the header element
horizontalbooleanundefined Transition the `width` instead of `height` and set a `width` on the immediate child element
idstringundefined The Id to be injected to accordion items and used to in BCollapse for state managment
is-navbooleanundefined When set, signifies that the accordion is part of a navbar, enabling certain features for navbar support
lazybooleanfalse When set, the content will not be mounted until opened
model-valuebooleanfalse Controls the visibility of the component
showbooleanfalse When set, and prop 'visible' is false on mount, will animate from closed to open on initial mount. Mainly to help with template show. Use model-value for reactive show/hide
tagstring'div' Specify the HTML tag to render instead of the default tag
titlestringundefined Text to place in the header of the AccordionItem (title slot takes precedence)
unmount-lazybooleanfalse When set and `lazy` is true, the content will be unmounted when closed
visiblebooleanfalse When 'true', open without animation
wrapper-attrsReadonly<AttrsValue>undefined Attributes to be applied to the wrapper element
EventArgsDescription
hiddenEmitted when AccordionItem has finished closing
hide
value: BvTriggerableEvent - Native triggerable event
Emitted when AccordionItem has started to close
hide-preventedEmitted when the AccordionItem tried to close, but was prevented from doing so.
show
value: BvTriggerableEvent - Native triggerable event
Emitted when AccordionItem has started to show
show-preventedEmitted when the AccordionItem tried to open, but was prevented from doing so.
shownEmitted when AccordionItem has finished showing
update:model-value
value: boolean - Current visibility state of the AccordionItem
Emitted when the visibility of the AccordionItem is changed
NameScopeDescription
defaultContent to place in the AccordionItem
titleContent to place in the header of the AccordionItem