Build vertically collapsing accordions in combination with our Collapse JavaScript plugin.

How it works

The accordion uses collapse internally to make it collapsible.

The animation effect of this component is dependent on the prefers-reduced-motion media query. See the reduced motion section of our accessibility documentation.

Example

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

To render an accordion that’s expanded by default:

  • add the .show class on the .accordion-collapse element.
  • drop the .collapsed class from the .accordion-button element and set its aria-expanded attribute to true.

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 .accordion-body, 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 .accordion-body, 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 .accordion-body, though the transition does limit overflow.
html
<div class="accordion" id="accordionExample">
  <div class="accordion-item">
    <h2 class="accordion-header">
      <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
        Accordion Item #1
      </button>
    </h2>
    <div id="collapseOne" class="accordion-collapse collapse show" data-bs-parent="#accordionExample">
      <div class="accordion-body">
        <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 <code>.accordion-body</code>, though the transition does limit overflow.
      </div>
    </div>
  </div>
  <div class="accordion-item">
    <h2 class="accordion-header">
      <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
        Accordion Item #2
      </button>
    </h2>
    <div id="collapseTwo" class="accordion-collapse collapse" data-bs-parent="#accordionExample">
      <div class="accordion-body">
        <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 <code>.accordion-body</code>, though the transition does limit overflow.
      </div>
    </div>
  </div>
  <div class="accordion-item">
    <h2 class="accordion-header">
      <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
        Accordion Item #3
      </button>
    </h2>
    <div id="collapseThree" class="accordion-collapse collapse" data-bs-parent="#accordionExample">
      <div class="accordion-body">
        <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 <code>.accordion-body</code>, though the transition does limit overflow.
      </div>
    </div>
  </div>
</div>

Sizes

Add .accordion-lg or .accordion-sm for additional sizes.

This is the first 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 .accordion-body, 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 .accordion-body, 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 .accordion-body, though the transition does limit overflow.

This is the first 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 .accordion-body, 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 .accordion-body, 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 .accordion-body, though the transition does limit overflow.
html
<div class="row">
  <div class="col-md-6 col-lg-5">
    <div class="accordion accordion-sm" id="accordionExampleSmall">
      <div class="accordion-item">
        <h2 class="accordion-header">
          <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOneSmall" aria-expanded="true" aria-controls="collapseOneSmall">
            Accordion Item #1
          </button>
        </h2>
        <div id="collapseOneSmall" class="accordion-collapse collapse show" data-bs-parent="#accordionExampleSmall">
          <div class="accordion-body">
            <strong>This is the first 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 <code>.accordion-body</code>, though the transition does limit overflow.
          </div>
        </div>
      </div>
      <div class="accordion-item">
        <h2 class="accordion-header">
          <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseTwoSmall" aria-expanded="false" aria-controls="collapseTwoSmall">
            Accordion Item #2
          </button>
        </h2>
        <div id="collapseTwoSmall" class="accordion-collapse collapse" data-bs-parent="#accordionExampleSmall">
          <div class="accordion-body">
            <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 <code>.accordion-body</code>, though the transition does limit overflow.
          </div>
        </div>
      </div>
      <div class="accordion-item">
        <h2 class="accordion-header">
          <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseThreeSmall" aria-expanded="false" aria-controls="collapseThreeSmall">
            Accordion Item #3
          </button>
        </h2>
        <div id="collapseThreeSmall" class="accordion-collapse collapse" data-bs-parent="#accordionExampleSmall">
          <div class="accordion-body">
            <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 <code>.accordion-body</code>, though the transition does limit overflow.
          </div>
        </div>
      </div>
    </div>
  </div>
  <div class="col-md-6 col-lg-7">
    <div class="accordion accordion-lg" id="accordionExampleLarge">
      <div class="accordion-item">
        <h2 class="accordion-header">
          <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOneLarge" aria-expanded="true" aria-controls="collapseOneLarge">
            Accordion Item #1
          </button>
        </h2>
        <div id="collapseOneLarge" class="accordion-collapse collapse show" data-bs-parent="#accordionExampleLarge">
          <div class="accordion-body">
            <strong>This is the first 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 <code>.accordion-body</code>, though the transition does limit overflow.
          </div>
        </div>
      </div>
      <div class="accordion-item">
        <h2 class="accordion-header">
          <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseTwoLarge" aria-expanded="false" aria-controls="collapseTwoLarge">
            Accordion Item #2
          </button>
        </h2>
        <div id="collapseTwoLarge" class="accordion-collapse collapse" data-bs-parent="#accordionExampleLarge">
          <div class="accordion-body">
            <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 <code>.accordion-body</code>, though the transition does limit overflow.
          </div>
        </div>
      </div>
      <div class="accordion-item">
        <h2 class="accordion-header">
          <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapseThreeLarge" aria-expanded="false" aria-controls="collapseThreeLarge">
            Accordion Item #3
          </button>
        </h2>
        <div id="collapseThreeLarge" class="accordion-collapse collapse" data-bs-parent="#accordionExampleLarge">
          <div class="accordion-body">
            <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 <code>.accordion-body</code>, though the transition does limit overflow.
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

Always open

Omit the data-bs-parent attribute on each .accordion-collapse to make accordion items stay open when another item is opened.

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 .accordion-body, 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 .accordion-body, 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 .accordion-body, though the transition does limit overflow.
html
<div class="accordion" id="accordionPanelsStayOpenExample">
  <div class="accordion-item">
    <h2 class="accordion-header">
      <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#panelsStayOpen-collapseOne" aria-expanded="true" aria-controls="panelsStayOpen-collapseOne">
        Accordion Item #1
      </button>
    </h2>
    <div id="panelsStayOpen-collapseOne" class="accordion-collapse collapse show">
      <div class="accordion-body">
        <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 <code>.accordion-body</code>, though the transition does limit overflow.
      </div>
    </div>
  </div>
  <div class="accordion-item">
    <h2 class="accordion-header">
      <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#panelsStayOpen-collapseTwo" aria-expanded="false" aria-controls="panelsStayOpen-collapseTwo">
        Accordion Item #2
      </button>
    </h2>
    <div id="panelsStayOpen-collapseTwo" class="accordion-collapse collapse">
      <div class="accordion-body">
        <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 <code>.accordion-body</code>, though the transition does limit overflow.
      </div>
    </div>
  </div>
  <div class="accordion-item">
    <h2 class="accordion-header">
      <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#panelsStayOpen-collapseThree" aria-expanded="false" aria-controls="panelsStayOpen-collapseThree">
        Accordion Item #3
      </button>
    </h2>
    <div id="panelsStayOpen-collapseThree" class="accordion-collapse collapse">
      <div class="accordion-body">
        <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 <code>.accordion-body</code>, though the transition does limit overflow.
      </div>
    </div>
  </div>
</div>

Dark variant

Deprecated in v5.3.3

Heads up! Dark variants for components are deprecated in Boosted v5.3.3. They are replaced by our contextual dark mode.

Add data-bs-theme="dark" to the .accordion or any ancestor element to enable a component-specific color mode. Learn more about our color modes.

Accessibility

Please read the collapse accessibility section for more information.

CSS

Variables

Added in v5.2.0

As part of Boosted’s evolving CSS variables approach, accordions now use local CSS variables on .accordion for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.

--#{$prefix}accordion-color: #{$accordion-color};
--#{$prefix}accordion-bg: #{$accordion-bg};
--#{$prefix}accordion-transition: #{$accordion-transition};
--#{$prefix}accordion-border-color: #{$accordion-border-color};
--#{$prefix}accordion-border-width: #{$accordion-border-width};
--#{$prefix}accordion-border-radius: #{$accordion-border-radius};
--#{$prefix}accordion-inner-border-radius: #{$accordion-inner-border-radius};
--#{$prefix}accordion-btn-padding-x: #{$accordion-button-padding-x};
--#{$prefix}accordion-btn-padding-y: #{$accordion-button-padding-y};
--#{$prefix}accordion-btn-font-size: #{$accordion-button-font-size}; // Boosted mod
--#{$prefix}accordion-btn-font-weight: #{$accordion-button-font-weight}; // Boosted mod
--#{$prefix}accordion-btn-line-height: #{$accordion-button-line-height}; // Boosted mod
--#{$prefix}accordion-btn-letter-spacing: #{$accordion-button-letter-spacing}; // Boosted mod
--#{$prefix}accordion-btn-color: #{$accordion-button-color};
--#{$prefix}accordion-btn-bg: #{$accordion-button-bg};
// Boosted mod: no --#{$prefix}accordion-btn-icon
// Boosted mod: no --#{$prefix}accordion-btn-icon-width
--#{$prefix}accordion-btn-icon-transform: #{$accordion-icon-transform};
// Boosted mod: no --#{$prefix}accordion-btn-icon-transition
// Boosted mod: no --#{$prefix}accordion-btn-active-icon
// Boosted mod: no --#{$prefix}accordion-btn-focus-box-shadow
--#{$prefix}accordion-body-padding-top: #{$accordion-body-padding-top}; // Boosted mod
--#{$prefix}accordion-body-padding-end: #{$accordion-body-padding-end}; // Boosted mod
--#{$prefix}accordion-body-padding-bottom: #{$accordion-body-padding-bottom}; // Boosted mod
--#{$prefix}accordion-body-padding-start: #{$accordion-body-padding-start}; // Boosted mod
--#{$prefix}accordion-btn-hover-bg: #{$accordion-button-hover-bg}; // Boosted mod
--#{$prefix}accordion-active-color: #{$accordion-button-active-color};
--#{$prefix}accordion-active-bg: #{$accordion-button-active-bg};

Small and large accordion modifier classes are used to update the value of these CSS variables as needed:

--#{$prefix}accordion-btn-font-size: #{$accordion-button-font-size-sm};
--#{$prefix}accordion-btn-line-height: #{$accordion-button-line-height-sm};
--#{$prefix}accordion-btn-letter-spacing: #{$accordion-button-letter-spacing-sm};
--#{$prefix}accordion-btn-font-size: #{$accordion-button-font-size-lg};
--#{$prefix}accordion-btn-line-height: #{$accordion-button-line-height-lg};
--#{$prefix}accordion-btn-letter-spacing: #{$accordion-button-letter-spacing-lg};

Sass variables

$accordion-padding-y:                     $spacer * .5; // Boosted mod
$accordion-padding-x:                     0; // Boosted mod
$accordion-color:                         null; // Boosted mod: instead of `var(--#{$prefix}body-color)`
$accordion-bg:                            transparent; // Boosted mod: instead of `var(--#{$prefix}body-bg)`
// stylelint-disable-next-line function-disallowed-list
$accordion-border-width:                  calc(var(--#{$prefix}border-width) * .5); // Boosted mod
$accordion-border-color:                  var(--#{$prefix}border-color-subtle); // Boosted mod: instead of `var(--#{$prefix}border-color)`
$accordion-border-radius:                 var(--#{$prefix}border-radius);
$accordion-inner-border-radius:           subtract($accordion-border-radius, #{$accordion-border-width});

$accordion-body-padding-top:              $spacer; // Boosted mod
$accordion-body-padding-end:              0; // Boosted mod
$accordion-body-padding-bottom:           $spacer * 1.5; // Boosted mod
$accordion-body-padding-start:            0; // Boosted mod
// fusv-disable
$accordion-body-padding-y:                $spacer; // Deprecated in Boosted 5.2.3 to divide it in -padding<top | end | bottom |start>
$accordion-body-padding-x:                $spacer; // Deprecated in Boosted 5.2.3 to divide it in -padding<top | end | bottom |start>
// fusv-enable

$accordion-button-padding-y:              $accordion-padding-y;
$accordion-button-padding-x:              $accordion-padding-x;
$accordion-button-color:                  null; // Boosted mod: instead of `var(--#{$prefix}body-color)`
$accordion-button-bg:                     var(--#{$prefix}accordion-bg);
$accordion-transition:                    $btn-transition, border-radius .15s ease;
$accordion-button-hover-bg:               var(--#{$prefix}secondary-bg); // Boosted mod
$accordion-button-active-bg:              null; // Boosted mod: instead of `var(--#{$prefix}primary-bg-subtle)`
$accordion-button-active-color:           $accordion-button-color; // Boosted mod: instead of `var(--#{$prefix}primary-text-emphasis)`

// Boosted mod: no $accordion-button-focus-border-color
// Boosted mod: no $accordion-button-focus-box-shadow

// Boosted mod: no $accordion-icon-width
// Boosted mod: no $accordion-icon-color
// Boosted mod: no $accordion-icon-active-color
// Boosted mod: no $accordion-icon-transition
$accordion-icon-transform:                scaleY(-1);

// Boosted mod: no $accordion-button-icon
// Boosted mod: no $accordion-button-active-icon

// Boosted mod: accordion sizes
$accordion-button-font-size:              $h3-font-size;
$accordion-button-line-height:            null;
$accordion-button-font-weight:            $font-weight-bold;
$accordion-button-letter-spacing:         $h3-spacing;
$accordion-button-font-size-sm:           $h5-font-size;
$accordion-button-line-height-sm:         $h5-line-height;
$accordion-button-letter-spacing-sm:      $h5-spacing;
$accordion-button-font-size-lg:           $h2-font-size;
$accordion-button-line-height-lg:         calc(40 / 30); // stylelint-disable-line function-disallowed-list
$accordion-button-letter-spacing-lg:      $h2-spacing;
// End mod