Collapse
Toggle the visibility of content across your project with a few classes and our JavaScript plugins.
How it works
The 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 it's 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.
Example
Click the buttons below to show and hide another element via class changes:
.collapse
hides content.collapsing
is applied during transitions.collapse.show
shows content
You can use a link with the href
attribute, or a button with the data-target
attribute. In both cases, the
data-toggle="collapse"
is required.
<p>
<a class="btn btn-primary" data-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample">
Link with href
</a>
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
Button with data-target
</button>
</p>
<div class="collapse" id="collapseExample">
<div class="card card-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
</div>
</div>
Multiple targets
A <button>
or <a>
can show and hide multiple elements by referencing them
with a JQuery selector in its href
or data-target
attribute.
Multiple <button>
or <a>
can show and hide an element if they each reference it with
their href
or data-target
attribute
<p>
<a class="btn btn-primary" data-toggle="collapse" href="#multiCollapseExample1" role="button" aria-expanded="false" aria-controls="multiCollapseExample1">Toggle first element</a>
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#multiCollapseExample2" aria-expanded="false" aria-controls="multiCollapseExample2">Toggle second element</button>
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target=".multi-collapse" aria-expanded="false" aria-controls="multiCollapseExample1 multiCollapseExample2">Toggle both elements</button>
</p>
<div class="row">
<div class="col">
<div class="collapse multi-collapse" id="multiCollapseExample1">
<div class="card card-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
</div>
</div>
</div>
<div class="col">
<div class="collapse multi-collapse" id="multiCollapseExample2">
<div class="card card-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
</div>
</div>
</div>
</div>
Accordion example
Using the card component, you can extend the default collapse
behavior to create an accordion. To properly achieve the accordion style, be sure to use #accordion
as a wrapper.
Investig ationes demons trave un lectoes legere kliusa quod thlegunt saepius claritas Investig ationes. Investig ationes demons trave runt lectoes legere kliusa. Investig ationes demons trave un lectoes legere kliusa quod thlegunt saepius claritas Investig atio nes. Investig ationes demons trave runt lectoes legere kliusa.
Investig ationes demons trave un lectoes legere kliusa quod thlegunt saepius claritas Investig ationes. Investig ationes demons trave runt lectoes legere kliusa. Investig ationes demons trave un lectoes legere kliusa quod thlegunt saepius claritas Investig atio nes. Investig ationes demons trave runt lectoes legere kliusa.
Investig ationes demons trave un lectoes legere kliusa quod thlegunt saepius claritas Investig ationes. Investig ationes demons trave runt lectoes legere kliusa. Investig ationes demons trave un lectoes legere kliusa quod thlegunt saepius claritas Investig atio nes. Investig ationes demons trave runt lectoes legere kliusa.
Investig ationes demons trave un lectoes legere kliusa quod thlegunt saepius claritas Investig ationes. Investig ationes demons trave runt lectoes legere kliusa. Investig ationes demons trave un lectoes legere kliusa quod thlegunt saepius claritas Investig atio nes. Investig ationes demons trave runt lectoes legere kliusa.
<div id="accordion" class="bg-white shadow">
<div class="accordion-item border-bottom border-light-v2">
<a href="#acc7_1" class="accordion__title h6 mb-0 p-4" data-toggle="collapse"
aria-expanded="true">
<span class="accordion__icon font-size-15 mr-2 mt-1">
<i class="fas fa-arrow-down"></i>
<i class="fas fa-arrow-up"></i>
</span>
What type of personal information do we collect?
</a>
<div id="acc7_1" class="collapse show" data-parent="#accordion" style="">
<div class="px-4">
<p>
Investig ationes demons trave un lectoes legere kliusa quod thlegunt saepius claritas
Investig ationes. Investig ationes demons trave runt lectoes legere kliusa. Investig ationes
demons trave un lectoes legere kliusa quod thlegunt saepius claritas Investig atio nes.
Investig ationes demons trave runt lectoes legere kliusa.
</p>
</div>
</div>
</div> <!-- END accordion-item-->
<div class="accordion-item border-bottom border-light-v2">
<a href="#acc7_3" class="accordion__title h6 mb-0 p-4 collapsed" data-toggle="collapse"
aria-expanded="false">
<span class="accordion__icon font-size-15 mr-2 mt-1">
<i class="fas fa-arrow-down"></i>
<i class="fas fa-arrow-up"></i>
</span>
How do we use personal information?
</a>
<div id="acc7_3" class="collapse" data-parent="#accordion">
<div class="px-4">
<p>
Investig ationes demons trave un lectoes legere kliusa quod thlegunt saepius claritas
Investig ationes. Investig ationes demons trave runt lectoes legere kliusa. Investig ationes
demons trave un lectoes legere kliusa quod thlegunt saepius claritas Investig atio nes.
Investig ationes demons trave runt lectoes legere kliusa.
</p>
</div>
</div>
</div> <!-- END accordion-item-->
<div class="accordion-item border-bottom border-light-v2">
<a href="#acc7_4" class="accordion__title h6 mb-0 p-4 collapsed" data-toggle="collapse"
aria-expanded="false">
<span class="accordion__icon font-size-15 mr-2 mt-1">
<i class="fas fa-arrow-down"></i>
<i class="fas fa-arrow-up"></i>
</span>
How we collect personal information?
</a>
<div id="acc7_4" class="collapse" data-parent="#accordion">
<div class="px-4">
<p>
Investig ationes demons trave un lectoes legere kliusa quod thlegunt saepius claritas
Investig ationes. Investig ationes demons trave runt lectoes legere kliusa. Investig ationes
demons trave un lectoes legere kliusa quod thlegunt saepius claritas Investig atio nes.
Investig ationes demons trave runt lectoes legere kliusa.
</p>
</div>
</div>
</div> <!-- END accordion-item-->
<div class="accordion-item border-bottom">
<a href="#acc7_5" class="accordion__title h6 mb-0 p-4 collapsed" data-toggle="collapse"
aria-expanded="false">
<span class="accordion__icon font-size-15 mr-2 mt-1">
<i class="fas fa-arrow-down"></i>
<i class="fas fa-arrow-up"></i>
</span>
When may we disclose your personal information?
</a>
<div id="acc7_5" class="collapse" data-parent="#accordion">
<div class="px-4">
<p>
Investig ationes demons trave un lectoes legere kliusa quod thlegunt saepius claritas
Investig ationes. Investig ationes demons trave runt lectoes legere kliusa. Investig ationes
demons trave un lectoes legere kliusa quod thlegunt saepius claritas Investig atio nes.
Investig ationes demons trave runt lectoes legere kliusa.
</p>
</div>
</div>
</div> <!-- END accordion-item-->
</div>
Accordion Spaced
Investig ationes demons trave runt lectoes legere kliusa quod thlegunt saepius claritas Investig ationes.
Investig ationes demons trave runt lectoes legere kliusa quod thlegunt saepius claritas Investig ationes.
Investig ationes demons trave runt lectoes legere kliusa quod thlegunt saepius claritas Investig ationes.
<div id="accordionExtend">
<div class="card accordion-item mb-3">
<a href="#acc4_1" class="accordion__title h6 border mb-0 p-3" data-toggle="collapse"
aria-expanded="true">
<i class="far fa-file-pdf mr-2"></i>
Do you have any built-in caching?
<span class="accordion__icon float-right small mt-1">
<i class="fas fa-plus"></i>
<i class="fas fa-minus"></i>
</span>
</a>
<div id="acc4_1" class="collapse show" data-parent="#accordionExtend" style="">
<div class="p-4 border border-top-0">
<p>
Investig ationes demons trave runt lectoes legere kliusa quod thlegunt saepius claritas
Investig ationes.
</p>
</div>
</div>
</div> <!-- END accordion-item-->
<div class="card accordion-item mb-3">
<a href="#acc4_2" class="accordion__title h6 border p-3 mb-0 collapsed" data-toggle="collapse"
aria-expanded="false">
<i class="fas fa-bookmark mr-2"></i>
Can I add/upgrade my plan at any time?
<span class="accordion__icon float-right small mt-1">
<i class="fas fa-plus"></i>
<i class="fas fa-minus"></i>
</span>
</a>
<div id="acc4_2" class="collapse" data-parent="#accordionExtend" style="">
<div class="p-4 border border-top-0">
<p>
Investig ationes demons trave runt lectoes legere kliusa quod thlegunt saepius claritas
Investig ationes.
</p>
</div>
</div>
</div> <!-- END accordion-item-->
<div class="card accordion-item mb-3">
<a href="#acc4_3" class="accordion__title h6 border p-3 mb-0 collapsed" data-toggle="collapse"
aria-expanded="false">
<i class="fas fa-lock mr-2"></i>
How do I change my password?
<span class="accordion__icon float-right small mt-1">
<i class="fas fa-plus"></i>
<i class="fas fa-minus"></i>
</span>
</a>
<div id="acc4_3" class="collapse" data-parent="#accordionExtend" style="">
<div class="p-4 border border-top-0">
<p>
Investig ationes demons trave runt lectoes legere kliusa quod thlegunt saepius claritas
Investig ationes.
</p>
</div>
</div>
</div> <!-- END accordion-item-->
</div>