Collapse · Bootstrap v5.0 | Bootstrap collapse menu
HowitworksThecollapseJavaScriptpluginisusedtoshowandhidecontent.Buttonsoranchorsareusedastriggersthataremappedtospecificelementsyoutoggle.Collapsinganelementwillanimatetheheightfromitscurrentvalueto0.GivenhowCSShandlesanimations,youcannotusepaddingona.collapseelement.Instead,usetheclassasanindependentwrappingelement.ExampleClickthebuttonsbelowtoshowandhideanotherelementviaclasschanges:.collapsehidescontent.collapsingisappliedduringtransitions.collapse.showshowscontentGenerally,werecommendusi...
How it worksThe collapse JavaScript plugin is used to show and hide content. Buttons or anchors are used as triggers that are mapped to specific elements you toggle. Collapsing an element will animate the height from its current value to 0. Given how CSS handles animations, you cannot use padding on a .collapse element. Instead, use the class as an independent wrapping element.
ExampleClick the buttons below to show and hide another element via class changes:
.collapse hides content .collapsing is applied during transitions .collapse.show shows contentGenerally, we recommend using a button with the data-bs-target attribute. While not recommended from a semantic point of view, you can also use a link with the href attribute (and a role="button"). In both cases, the data-bs-toggle="collapse" is required.
Link with href [1] Button with data-bs-target
Some placeholder content for the collapse component. This panel...