![]() |
VOOZH | about |
Bootstrap 5 Accordion Always open is used to change the default value of Accordion and change it to always-open accordion where if a tab of it is open then it will stay open until it is toggled to close by eliminating the data-bs-parent attribute with each accordion tab with the .accordion-collapse class.
Bootstrap5 Accordion Always open Classes: No special class is used to implement the always-on setting of the accordion, the only change which is needed is to omit the attribute.
Syntax:
<div class="accordion" id=" ">
<div class="accordion-item">
<h2 class="accordion-header" id=" ">
...
</h2>
<div id=" " class="accordion-collapse">
<div class="accordion-body">
. . . . .
</div>
</div>
</div>
<div class="accordion-item">...</div>
</div>
Example 1: The code example demonstrates how we can implement an always open simple accordion:
Output:
Example 2: The code below demonstrates how we can collapse an always-on accordion which is implemented above:
Output:
Reference:https://getbootstrap.com/docs/5.0/components/accordion/#always-open