Accordion
Build vertically collapsing accordions in combination with our Collapse JavaScript plugin.
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
.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.
<div class="accordion" id="accordionExample">
<div class="border border-gray-400 rounded-md mb-3">
<h2 class="accordion-header px-4 py-3">
<button
class="text-lg fw-semibold flex items-center w-full
justify-between"
type="button"
data-bs-toggle="collapse"
data-bs-target="#collapseOne"
aria-expanded="true"
aria-controls="collapseOne"
>
<span>Accordion Item #1</span>
<span>
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="feather feather-chevron-down
collapse-icon"
>
<polyline points="6 9 12 15 18 9"></polyline>
</svg>
</span>
</button>
</h2>
<div id="collapseOne" class="accordion-collapse collapse show" data-bs-parent="#accordionExample">
<div class="accordion-body px-4 py-3 border-t
border-gray-400">
<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="border border-gray-400 rounded-md mb-3">
<h2 class="accordion-header px-4 py-3">
<button
class="text-lg fw-semibold flex items-center w-full
justify-between"
type="button"
data-bs-toggle="collapse"
data-bs-target="#collapseTwo"
aria-expanded="false"
aria-controls="collapseTwo"
>
<span>Accordion Item #2</span>
<span>
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="feather feather-chevron-down
collapse-icon"
>
<polyline points="6 9 12 15 18 9"></polyline>
</svg>
</span>
</button>
</h2>
<div id="collapseTwo" class="accordion-collapse collapse" data-bs-parent="#accordionExample">
<div class="accordion-body px-4 py-3 border-t
border-gray-400">
<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="border border-gray-400 rounded-md mb-3">
<h2 class="accordion-header px-4 py-3">
<button
class="text-lg fw-semibold flex items-center w-full
justify-between"
type="button"
data-bs-toggle="collapse"
data-bs-target="#collapseThree"
aria-expanded="false"
aria-controls="collapseThree"
>
<span>Accordion Item #3</span>
<span>
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="feather feather-chevron-down
collapse-icon"
>
<polyline points="6 9 12 15 18 9"></polyline>
</svg>
</span>
</button>
</h2>
<div id="collapseThree" class="accordion-collapse collapse" data-bs-parent="#accordionExample">
<div class="accordion-body px-4 py-3 border-t
border-gray-400">
<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>