How it works
The accordion uses collapse internally to make it collapsible.
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.
<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>
<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>
Flush
Add .accordion-flush to remove some borders and rounded corners to render accordions
edge-to-edge with their parent container.
Placeholder content for this accordion, which is intended to demonstrate the
.accordion-flush class. This is the first item’s accordion body.
Placeholder content for this accordion, which is intended to demonstrate the
.accordion-flush class. This is the second item’s accordion body. Let’s
imagine this being filled with some actual content.
Placeholder content for this accordion, which is intended to demonstrate the
.accordion-flush class. 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.
<div class="accordion accordion-flush" id="accordionFlushExample">
<div class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#flush-collapseOne" aria-expanded="false" aria-controls="flush-collapseOne">
Accordion Item #1
</button>
</h2>
<div id="flush-collapseOne" class="accordion-collapse collapse" data-bs-parent="#accordionFlushExample">
<div class="accordion-body">Placeholder content for this accordion, which is intended to demonstrate the <code>.accordion-flush</code> class. This is the first item’s accordion body.</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="#flush-collapseTwo" aria-expanded="false" aria-controls="flush-collapseTwo">
Accordion Item #2
</button>
</h2>
<div id="flush-collapseTwo" class="accordion-collapse collapse" data-bs-parent="#accordionFlushExample">
<div class="accordion-body">Placeholder content for this accordion, which is intended to demonstrate the <code>.accordion-flush</code> class. This is the second item’s accordion body. Let’s imagine this being filled with some actual content.</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="#flush-collapseThree" aria-expanded="false" aria-controls="flush-collapseThree">
Accordion Item #3
</button>
</h2>
<div id="flush-collapseThree" class="accordion-collapse collapse" data-bs-parent="#accordionFlushExample">
<div class="accordion-body">Placeholder content for this accordion, which is intended to demonstrate the <code>.accordion-flush</code> class. 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.</div>
</div>
</div>
</div>
<div class="accordion accordion-flush" id="accordionFlushExample">
<div class="accordion-item"> <h2 class="accordion-header">
<button class="accordion-button collapsed" type="button"
data-bs-toggle="collapse" data-bs-target="#flush-collapseOne"
aria-expanded="false" aria-controls="flush-collapseOne"> Accordion Item
#1 </button> </h2> <div id="flush-collapseOne"
class="accordion-collapse collapse"
data-bs-parent="#accordionFlushExample"> <div
class="accordion-body">Placeholder content for this accordion, which is intended to
demonstrate the <code>.accordion-flush</code> class. This is the first item’s
accordion body.</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="#flush-collapseTwo"
aria-expanded="false" aria-controls="flush-collapseTwo"> Accordion Item
#2 </button> </h2> <div id="flush-collapseTwo"
class="accordion-collapse collapse"
data-bs-parent="#accordionFlushExample"> <div
class="accordion-body">Placeholder content for this accordion, which is intended to
demonstrate the <code>.accordion-flush</code> class. This is the second item’s
accordion body. Let’s imagine this being filled with some actual content.</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="#flush-collapseThree" aria-expanded="false"
aria-controls="flush-collapseThree"> Accordion Item #3 </button> </h2>
<div id="flush-collapseThree" class="accordion-collapse collapse"
data-bs-parent="#accordionFlushExample"> <div
class="accordion-body">Placeholder content for this accordion, which is intended to
demonstrate the <code>.accordion-flush</code> class. 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.</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.
<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>
<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>
Accordion with icon
Each section in the icon-enhanced accordion includes a relevant icon beside the title, adding visual
context to the content within.
Enhanced visual communication. Icons provide immediate context and help
users quickly identify different content sections and categories.
Intuitive content discovery. Icons serve as visual cues that help users
scan and locate specific information more efficiently.
Brand consistency. Custom icons can reinforce your brand identity while
maintaining the functional benefits of visual categorization.
Inclusive design approach. Icons complement text content and support
users with different learning styles and accessibility needs.
<div class="accordion accordion-flush accordion-icon" id="iconAccordion" role="tablist" aria-multiselectable="true">
<div class="accordion-item border rounded mb-3">
<h2 class="accordion-header">
<button class="accordion-button collapsed rounded shadow-none" type="button" data-bs-toggle="collapse" data-bs-target="#icon1" aria-expanded="false" aria-controls="icon1">
<i class="ri-layout-grid-line me-2"></i>Icon Enhancement: Visual Context
</button>
</h2>
<div id="icon1" class="accordion-collapse collapse" data-bs-parent="#iconAccordion">
<div class="accordion-body">
<strong>Enhanced visual communication.</strong> Icons provide immediate context and help users quickly identify different content sections and categories.
</div>
</div>
</div>
<div class="accordion-item border rounded mb-3">
<h2 class="accordion-header">
<button class="accordion-button collapsed rounded shadow-none" type="button" data-bs-toggle="collapse" data-bs-target="#icon2" aria-expanded="false" aria-controls="icon2">
<i class="ri-star-line me-2"></i>User Experience: Improved Navigation
</button>
</h2>
<div id="icon2" class="accordion-collapse collapse" data-bs-parent="#iconAccordion">
<div class="accordion-body">
<strong>Intuitive content discovery.</strong> Icons serve as visual cues that help users scan and locate specific information more efficiently.
</div>
</div>
</div>
<div class="accordion-item border rounded mb-3">
<h2 class="accordion-header">
<button class="accordion-button collapsed rounded shadow-none" type="button" data-bs-toggle="collapse" data-bs-target="#icon3" aria-expanded="false" aria-controls="icon3">
<i class="ri-tools-line me-2"></i>Customization: Brand Integration
</button>
</h2>
<div id="icon3" class="accordion-collapse collapse" data-bs-parent="#iconAccordion">
<div class="accordion-body">
<strong>Brand consistency.</strong> Custom icons can reinforce your brand identity while maintaining the functional benefits of visual categorization.
</div>
</div>
</div>
<div class="accordion-item border rounded mb-3">
<h2 class="accordion-header">
<button class="accordion-button collapsed rounded shadow-none" type="button" data-bs-toggle="collapse" data-bs-target="#icon4" aria-expanded="false" aria-controls="icon4">
<i class="ri-palette-line me-2"></i>Accessibility: Universal Design
</button>
</h2>
<div id="icon4" class="accordion-collapse collapse" data-bs-parent="#iconAccordion">
<div class="accordion-body">
<strong>Inclusive design approach.</strong> Icons complement text content and support users with different learning styles and accessibility needs.
</div>
</div>
</div>
</div>
<div class="accordion accordion-flush accordion-icon" id="iconAccordion"
role="tablist" aria-multiselectable="true"> <div
class="accordion-item border rounded mb-3"> <h2
class="accordion-header"> <button class="accordion-button collapsed rounded
shadow-none" type="button" data-bs-toggle="collapse"
data-bs-target="#icon1" aria-expanded="false"
aria-controls="icon1"> <i class="ri-layout-grid-line
me-2"></i>Icon Enhancement: Visual Context </button> </h2> <div
id="icon1" class="accordion-collapse collapse"
data-bs-parent="#iconAccordion"> <div class="accordion-body">
<strong>Enhanced visual communication.</strong> Icons provide immediate context and
help users quickly identify different content sections and categories. </div> </div>
</div> <div class="accordion-item border rounded mb-3"> <h2
class="accordion-header"> <button class="accordion-button collapsed rounded
shadow-none" type="button" data-bs-toggle="collapse"
data-bs-target="#icon2" aria-expanded="false"
aria-controls="icon2"> <i class="ri-star-line me-2"></i>User
Experience: Improved Navigation </button> </h2> <div id="icon2"
class="accordion-collapse collapse" data-bs-parent="#iconAccordion">
<div class="accordion-body"> <strong>Intuitive content
discovery.</strong> Icons serve as visual cues that help users scan and locate specific
information more efficiently. </div> </div> </div> <div
class="accordion-item border rounded mb-3"> <h2
class="accordion-header"> <button class="accordion-button collapsed rounded
shadow-none" type="button" data-bs-toggle="collapse"
data-bs-target="#icon3" aria-expanded="false"
aria-controls="icon3"> <i class="ri-tools-line
me-2"></i>Customization: Brand Integration </button> </h2> <div
id="icon3" class="accordion-collapse collapse"
data-bs-parent="#iconAccordion"> <div class="accordion-body">
<strong>Brand consistency.</strong> Custom icons can reinforce your brand identity
while maintaining the functional benefits of visual categorization. </div> </div>
</div> <div class="accordion-item border rounded mb-3"> <h2
class="accordion-header"> <button class="accordion-button collapsed rounded
shadow-none" type="button" data-bs-toggle="collapse"
data-bs-target="#icon4" aria-expanded="false"
aria-controls="icon4"> <i class="ri-palette-line
me-2"></i>Accessibility: Universal Design </button> </h2> <div
id="icon4" class="accordion-collapse collapse"
data-bs-parent="#iconAccordion"> <div class="accordion-body">
<strong>Inclusive design approach.</strong> Icons complement text content and
support users with different learning styles and accessibility needs. </div> </div>
</div> </div>
Accordion with background
This accordion variant features a bordered background that visually separates each panel, enhancing
readability and structure.
Enhanced visual presentation. The background styling provides clear
section boundaries and improved visual hierarchy for better content organization.
Improved content organization. Background borders create distinct visual
sections that help users navigate complex information structures.
Focused reading experience. The bordered design helps users focus on
individual sections while maintaining the overall interface structure.
<div class="accordion accordion-flush" id="bgAccordion" role="tablist" aria-multiselectable="true">
<div class="accordion-item border rounded mb-3">
<h2 class="accordion-header">
<button class="accordion-button collapsed rounded shadow-none" type="button" data-bs-toggle="collapse" data-bs-target="#bg1" aria-expanded="false" aria-controls="bg1">
<i class="ri-image-line me-2"></i>Background Styling: Visual Enhancement
</button>
</h2>
<div id="bg1" class="accordion-collapse collapse" data-bs-parent="#bgAccordion">
<div class="accordion-body">
<strong>Enhanced visual presentation.</strong> The background styling provides clear section boundaries and improved visual hierarchy for better content organization.
</div>
</div>
</div>
<div class="accordion-item border rounded mb-3">
<h2 class="accordion-header">
<button class="accordion-button collapsed rounded shadow-none" type="button" data-bs-toggle="collapse" data-bs-target="#bg2" aria-expanded="false" aria-controls="bg2">
<i class="ri-contrast-2-line me-2"></i>Visual Separation: Clear Boundaries
</button>
</h2>
<div id="bg2" class="accordion-collapse collapse" data-bs-parent="#bgAccordion">
<div class="accordion-body">
<strong>Improved content organization.</strong> Background borders create distinct visual sections that help users navigate complex information structures.
</div>
</div>
</div>
<div class="accordion-item border rounded mb-3">
<h2 class="accordion-header">
<button class="accordion-button collapsed rounded shadow-none" type="button" data-bs-toggle="collapse" data-bs-target="#bg3" aria-expanded="false" aria-controls="bg3">
<i class="ri-focus-3-line me-2"></i>User Experience: Enhanced Readability
</button>
</h2>
<div id="bg3" class="accordion-collapse collapse" data-bs-parent="#bgAccordion">
<div class="accordion-body">
<strong>Focused reading experience.</strong> The bordered design helps users focus on individual sections while maintaining the overall interface structure.
</div>
</div>
</div>
</div>
<div class="accordion accordion-flush" id="bgAccordion"
role="tablist" aria-multiselectable="true"> <div
class="accordion-item border rounded mb-3"> <h2
class="accordion-header"> <button class="accordion-button collapsed rounded
shadow-none" type="button" data-bs-toggle="collapse"
data-bs-target="#bg1" aria-expanded="false"
aria-controls="bg1"> <i class="ri-image-line
me-2"></i>Background Styling: Visual Enhancement </button> </h2>
<div id="bg1" class="accordion-collapse collapse"
data-bs-parent="#bgAccordion"> <div class="accordion-body">
<strong>Enhanced visual presentation.</strong> The background styling provides clear
section boundaries and improved visual hierarchy for better content organization. </div>
</div> </div> <div class="accordion-item border rounded mb-3">
<h2 class="accordion-header"> <button class="accordion-button collapsed
rounded shadow-none" type="button" data-bs-toggle="collapse"
data-bs-target="#bg2" aria-expanded="false"
aria-controls="bg2"> <i class="ri-contrast-2-line
me-2"></i>Visual Separation: Clear Boundaries </button> </h2> <div
id="bg2" class="accordion-collapse collapse"
data-bs-parent="#bgAccordion"> <div class="accordion-body">
<strong>Improved content organization.</strong> Background borders create distinct
visual sections that help users navigate complex information structures. </div>
</div> </div> <div class="accordion-item border rounded mb-3">
<h2 class="accordion-header"> <button class="accordion-button collapsed
rounded shadow-none" type="button" data-bs-toggle="collapse"
data-bs-target="#bg3" aria-expanded="false"
aria-controls="bg3"> <i class="ri-focus-3-line me-2"></i>User
Experience: Enhanced Readability </button> </h2> <div id="bg3"
class="accordion-collapse collapse" data-bs-parent="#bgAccordion">
<div class="accordion-body"> <strong>Focused reading
experience.</strong> The bordered design helps users focus on individual sections while
maintaining the overall interface structure. </div> </div> </div> </div>
Accordion without arrow
Designed for minimal interfaces, the accordion without arrow removes toggle icons while retaining full
expand-and-collapse functionality.
Ultra-clean interface design. Removing visual indicators creates a more
streamlined appearance while maintaining full accordion functionality.
Intuitive user interaction. Users rely on hover states and cursor changes
to understand interactive elements, creating a cleaner aesthetic.
Content-focused approach. By removing visual distractions, the design
emphasizes the actual content and information hierarchy.
<div class="accordion accordion-flush accordion-without-arrow" id="noArrowAccordion" role="tablist" aria-multiselectable="true">
<div class="accordion-item border rounded mb-3">
<h2 class="accordion-header">
<button class="accordion-button collapsed rounded shadow-none" type="button" data-bs-toggle="collapse" data-bs-target="#noArrow1" aria-expanded="false" aria-controls="noArrow1">
<i class="ri-subtract-line me-2"></i>Minimal Interface: No Arrow Design
</button>
</h2>
<div id="noArrow1" class="accordion-collapse collapse" data-bs-parent="#noArrowAccordion">
<div class="accordion-body">
<strong>Ultra-clean interface design.</strong> Removing visual indicators creates a more streamlined appearance while maintaining full accordion functionality.
</div>
</div>
</div>
<div class="accordion-item border rounded mb-3">
<h2 class="accordion-header">
<button class="accordion-button collapsed rounded shadow-none" type="button" data-bs-toggle="collapse" data-bs-target="#noArrow2" aria-expanded="false" aria-controls="noArrow2">
<i class="ri-eye-line me-2"></i>Subtle Interaction: Implicit Navigation
</button>
</h2>
<div id="noArrow2" class="accordion-collapse collapse" data-bs-parent="#noArrowAccordion">
<div class="accordion-body">
<strong>Intuitive user interaction.</strong> Users rely on hover states and cursor changes to understand interactive elements, creating a cleaner aesthetic.
</div>
</div>
</div>
<div class="accordion-item border rounded mb-3">
<h2 class="accordion-header">
<button class="accordion-button collapsed rounded shadow-none" type="button" data-bs-toggle="collapse" data-bs-target="#noArrow3" aria-expanded="false" aria-controls="noArrow3">
<i class="ri-check-line me-2"></i>Content Priority: Information First
</button>
</h2>
<div id="noArrow3" class="accordion-collapse collapse" data-bs-parent="#noArrowAccordion">
<div class="accordion-body">
<strong>Content-focused approach.</strong> By removing visual distractions, the design emphasizes the actual content and information hierarchy.
</div>
</div>
</div>
</div>
<div class="accordion accordion-flush accordion-without-arrow"
id="noArrowAccordion" role="tablist"
aria-multiselectable="true"> <div class="accordion-item border rounded
mb-3"> <h2 class="accordion-header"> <button
class="accordion-button collapsed rounded shadow-none" type="button"
data-bs-toggle="collapse" data-bs-target="#noArrow1"
aria-expanded="false" aria-controls="noArrow1"> <i
class="ri-subtract-line me-2"></i>Minimal Interface: No Arrow Design
</button> </h2> <div id="noArrow1" class="accordion-collapse
collapse" data-bs-parent="#noArrowAccordion"> <div
class="accordion-body"> <strong>Ultra-clean interface design.</strong>
Removing visual indicators creates a more streamlined appearance while maintaining full
accordion functionality. </div> </div> </div> <div
class="accordion-item border rounded mb-3"> <h2
class="accordion-header"> <button class="accordion-button collapsed rounded
shadow-none" type="button" data-bs-toggle="collapse"
data-bs-target="#noArrow2" aria-expanded="false"
aria-controls="noArrow2"> <i class="ri-eye-line
me-2"></i>Subtle Interaction: Implicit Navigation </button> </h2>
<div id="noArrow2" class="accordion-collapse collapse"
data-bs-parent="#noArrowAccordion"> <div class="accordion-body">
<strong>Intuitive user interaction.</strong> Users rely on hover states and cursor
changes to understand interactive elements, creating a cleaner aesthetic. </div>
</div> </div> <div class="accordion-item border rounded mb-3">
<h2 class="accordion-header"> <button class="accordion-button collapsed
rounded shadow-none" type="button" data-bs-toggle="collapse"
data-bs-target="#noArrow3" aria-expanded="false"
aria-controls="noArrow3"> <i class="ri-check-line
me-2"></i>Content Priority: Information First </button> </h2> <div
id="noArrow3" class="accordion-collapse collapse"
data-bs-parent="#noArrowAccordion"> <div class="accordion-body">
<strong>Content-focused approach.</strong> By removing visual distractions, the
design emphasizes the actual content and information hierarchy. </div> </div>
</div> </div>
Accordion with indicator
Designed for intuitive interaction, the accordion with indicator replaces traditional arrows with plus
and minus icons that reflect the open or closed state of each section.
Clear visual feedback. Plus and minus indicators provide intuitive visual
cues about panel states and user interactions.
Recognizable interaction patterns. Users immediately understand the
expand/collapse functionality through familiar plus/minus iconography.
Flexible customization options. The indicator style can be easily
modified to match your design system requirements and brand guidelines.
<div class="accordion indicator-accordion" id="indicatorAccordion" role="tablist" aria-multiselectable="true">
<div class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button shadow-none collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#indicator1" aria-expanded="false" aria-controls="indicator1">
<i class="ri-add-circle-line me-2"></i>Indicator Design: Plus/Minus Icons
<span class="accordion-icon"></span>
</button>
</h2>
<div id="indicator1" class="accordion-collapse collapse" data-bs-parent="#indicatorAccordion">
<div class="accordion-body">
<strong>Clear visual feedback.</strong> Plus and minus indicators provide intuitive visual cues about panel states and user interactions.
</div>
</div>
</div>
<div class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button shadow-none collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#indicator2" aria-expanded="false" aria-controls="indicator2">
<i class="ri-user-line me-2"></i>User Interface: Familiar Patterns
<span class="accordion-icon"></span>
</button>
</h2>
<div id="indicator2" class="accordion-collapse collapse" data-bs-parent="#indicatorAccordion">
<div class="accordion-body">
<strong>Recognizable interaction patterns.</strong> Users immediately understand the expand/collapse functionality through familiar plus/minus iconography.
</div>
</div>
</div>
<div class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button shadow-none collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#indicator3" aria-expanded="false" aria-controls="indicator3">
<i class="ri-settings-3-line me-2"></i>Implementation: Custom Styling
<span class="accordion-icon"></span>
</button>
</h2>
<div id="indicator3" class="accordion-collapse collapse" data-bs-parent="#indicatorAccordion">
<div class="accordion-body">
<strong>Flexible customization options.</strong> The indicator style can be easily modified to match your design system requirements and brand guidelines.
</div>
</div>
</div>
</div>
<div class="accordion indicator-accordion" id="indicatorAccordion"
role="tablist" aria-multiselectable="true"> <div
class="accordion-item"> <h2 class="accordion-header"> <button
class="accordion-button shadow-none collapsed" type="button"
data-bs-toggle="collapse" data-bs-target="#indicator1"
aria-expanded="false" aria-controls="indicator1"> <i
class="ri-add-circle-line me-2"></i>Indicator Design: Plus/Minus Icons
<span class="accordion-icon"></span> </button> </h2> <div
id="indicator1" class="accordion-collapse collapse"
data-bs-parent="#indicatorAccordion"> <div class="accordion-body">
<strong>Clear visual feedback.</strong> Plus and minus indicators provide intuitive
visual cues about panel states and user interactions. </div> </div> </div>
<div class="accordion-item"> <h2 class="accordion-header">
<button class="accordion-button shadow-none collapsed" type="button"
data-bs-toggle="collapse" data-bs-target="#indicator2"
aria-expanded="false" aria-controls="indicator2"> <i
class="ri-user-line me-2"></i>User Interface: Familiar Patterns <span
class="accordion-icon"></span> </button> </h2> <div
id="indicator2" class="accordion-collapse collapse"
data-bs-parent="#indicatorAccordion"> <div class="accordion-body">
<strong>Recognizable interaction patterns.</strong> Users immediately understand the
expand/collapse functionality through familiar plus/minus iconography. </div> </div>
</div> <div class="accordion-item"> <h2
class="accordion-header"> <button class="accordion-button shadow-none
collapsed" type="button" data-bs-toggle="collapse"
data-bs-target="#indicator3" aria-expanded="false"
aria-controls="indicator3"> <i class="ri-settings-3-line
me-2"></i>Implementation: Custom Styling <span
class="accordion-icon"></span> </button> </h2> <div
id="indicator3" class="accordion-collapse collapse"
data-bs-parent="#indicatorAccordion"> <div class="accordion-body">
<strong>Flexible customization options.</strong> The indicator style can be easily
modified to match your design system requirements and brand guidelines. </div>
</div> </div> </div>
Accessibility
Please read the
collapse accessibility section for more
information.
Usage
The collapse plugin utilizes a few classes to handle the heavy lifting:
.collapse hides the content
.collapse.show shows the content
.collapsing is added when the transition starts, and removed when it finishes
These classes can be found in _transitions.scss.
Via data attributes
Just add data-bs-toggle="collapse" and a data-bs-target to the
element to automatically assign control of one or more collapsible elements. The
data-bs-target attribute accepts a CSS selector to apply the collapse to. Be sure to add
the class collapse to the collapsible element. If you’d like it to default open, add the
additional class show.
To add accordion group management to a collapsible area, add the data attribute
data-bs-parent="#selector".
Via JavaScript
Enable manually with:
const accordionCollapseElementList = document.querySelectorAll('#myAccordion .collapse');
const accordionCollapseList = [...accordionCollapseElementList].map(
(accordionCollapseEl) => new bootstrap.Collapse(accordionCollapseEl)
);
Options
As options can be passed via data attributes or JavaScript, you can append an option name to
data-bs-, as in data-bs-animation="{value}". Make sure to change
the case type of the option name from “camelCase” to “kebab-case” when passing the options via data
attributes. For example, use data-bs-custom-class="beautifier" instead of
data-bs-customClass="beautifier".
As of Bootstrap 5.2.0, all components support an experimental reserved data attribute
data-bs-config that can house simple component configuration as a JSON string. When an
element has data-bs-config='{"delay":0, "title":123}' and
data-bs-title="456" attributes, the final title value will be
456 and the separate data attributes will override values given on
data-bs-config. In addition, existing data attributes are able to house JSON values like
data-bs-delay='{"show":0,"hide":150}'.
The final configuration object is the merged result of data-bs-config,
data-bs-, and js object where the latest given key-value overrides the
others.
| Name |
Type |
Default |
Description |
parent |
selector, DOM element |
null |
If parent is provided, then all collapsible elements under the specified parent will be closed
when this collapsible item is shown. (similar to traditional accordion behavior - this is
dependent on the card class). The attribute has to be set on the target
collapsible area.
|
toggle |
boolean |
true |
Toggles the collapsible element on invocation. |
Methods
All API methods are asynchronous and start a transition. They return to the caller
as soon as the transition is started, but before it ends. In addition, a method call on a
transitioning component will be ignored. Learn more in our
JavaScript docs.
Activates your content as a collapsible element. Accepts an optional options object.
You can create a collapse instance with the constructor, for example:
const bsCollapse = new bootstrap.Collapse('#myCollapse', {
toggle: false
});
| Method |
Description |
dispose |
Destroys an element’s collapse. (Removes stored data on the DOM element) |
getInstance |
Static method which allows you to get the collapse instance associated to a DOM element, you
can use it like this: bootstrap.Collapse.getInstance(element).
|
getOrCreateInstance |
Static method which returns a collapse instance associated to a DOM element or create a new
one in case it wasn’t initialized. You can use it like this:
bootstrap.Collapse.getOrCreateInstance(element).
|
hide |
Hides a collapsible element.
Returns to the caller before the collapsible element has actually been hidden
(e.g., before the hidden.bs.collapse event occurs).
|
show |
Shows a collapsible element.
Returns to the caller before the collapsible element has actually been shown
(e.g., before the shown.bs.collapse event occurs).
|
toggle |
Toggles a collapsible element to shown or hidden.
Returns to the caller before the collapsible element has actually been shown or
hidden
(i.e. before the shown.bs.collapse or hidden.bs.collapse event
occurs).
|
Events
Bootstrap’s collapse class exposes a few events for hooking into collapse functionality.
| Event type |
Description |
hide.bs.collapse |
This event is fired immediately when the hide method has been called. |
hidden.bs.collapse |
This event is fired when a collapse element has been hidden from the user (will wait for CSS
transitions to complete).
|
show.bs.collapse |
This event fires immediately when the show instance method is called. |
shown.bs.collapse |
This event is fired when a collapse element has been made visible to the user (will wait for
CSS transitions to complete).
|
const myCollapsible = document.getElementById('myCollapsible');
myCollapsible.addEventListener('hidden.bs.collapse', (event) => {
});