ℹ️ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | PASS | download_stamp > now() - 6 MONTH | 0 months ago |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://getbootstrap.com/docs/4.0/components/collapse/ |
| Last Crawled | 2026-04-07 01:07:09 (1 day ago) |
| First Indexed | 2017-08-17 22:01:06 (8 years ago) |
| HTTP Status Code | 200 |
| Meta Title | Collapse · Bootstrap |
| Meta Description | Toggle the visibility of content across your project with a few classes and our JavaScript plugins. |
| Meta Canonical | null |
| Boilerpipe Text | Toggle the visibility of content across your project with a few classes and our JavaScript plugins.
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.
Link with href
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.
<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
Toggle first element
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.
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.
<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.
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
<div
id=
"accordion"
>
<div
class=
"card"
>
<div
class=
"card-header"
id=
"headingOne"
>
<h5
class=
"mb-0"
>
<button
class=
"btn btn-link"
data-toggle=
"collapse"
data-target=
"#collapseOne"
aria-expanded=
"true"
aria-controls=
"collapseOne"
>
Collapsible Group Item #1
</button>
</h5>
</div>
<div
id=
"collapseOne"
class=
"collapse show"
aria-labelledby=
"headingOne"
data-parent=
"#accordion"
>
<div
class=
"card-body"
>
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
<div
class=
"card"
>
<div
class=
"card-header"
id=
"headingTwo"
>
<h5
class=
"mb-0"
>
<button
class=
"btn btn-link collapsed"
data-toggle=
"collapse"
data-target=
"#collapseTwo"
aria-expanded=
"false"
aria-controls=
"collapseTwo"
>
Collapsible Group Item #2
</button>
</h5>
</div>
<div
id=
"collapseTwo"
class=
"collapse"
aria-labelledby=
"headingTwo"
data-parent=
"#accordion"
>
<div
class=
"card-body"
>
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
<div
class=
"card"
>
<div
class=
"card-header"
id=
"headingThree"
>
<h5
class=
"mb-0"
>
<button
class=
"btn btn-link collapsed"
data-toggle=
"collapse"
data-target=
"#collapseThree"
aria-expanded=
"false"
aria-controls=
"collapseThree"
>
Collapsible Group Item #3
</button>
</h5>
</div>
<div
id=
"collapseThree"
class=
"collapse"
aria-labelledby=
"headingThree"
data-parent=
"#accordion"
>
<div
class=
"card-body"
>
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
</div>
Accessibility
Be sure to add
aria-expanded
to the control element. This attribute explicitly conveys the current state of the collapsible element tied to the control to screen readers and similar assistive technologies. If the collapsible element is closed by default, the attribute on the control element should have a value of
aria-expanded="false"
. If you’ve set the collapsible element to be open by default using the
show
class, set
aria-expanded="true"
on the control instead. The plugin will automatically toggle this attribute on the control based on whether or not the collapsible element has been opened or closed (via JavaScript, or because the user triggered another control element also tied to the same collapsbile element). If the control element’s HTML element is not a button (e.g., an
<a>
or
<div>
), the attribute
role="button"
should be added to the element.
If your control element is targeting a single collapsible element – i.e. the
data-target
attribute is pointing to an
id
selector – you should add the
aria-controls
attribute to the control element, containing the
id
of the collapsible element. Modern screen readers and similar assistive technologies make use of this attribute to provide users with additional shortcuts to navigate directly to the collapsible element itself.
Note that Bootstrap’s current implementation does not cover the various keyboard interactions described in the
WAI-ARIA Authoring Practices 1.1 accordion pattern
- you will need to include these yourself with custom JavaScript.
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-toggle="collapse"
and a
data-target
to the element to automatically assign control of one or more collapsible elements. The
data-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-like group management to a collapsible area, add the data attribute
data-parent="#selector"
. Refer to the demo to see this in action.
Via JavaScript
Enable manually with:
$
(
'.collapse'
).
collapse
()
Options
Options can be passed via data attributes or JavaScript. For data attributes, append the option name to
data-
, as in
data-parent=""
.
Name
Type
Default
Description
parent
selector | jQuery object | DOM element
false
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
Asynchronous methods and transitions
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
.
See our JavaScript documentation for more information.
.collapse(options)
Activates your content as a collapsible element. Accepts an optional options
object
.
$
(
'#myCollapsible'
).
collapse
({
toggle
:
false
})
.collapse('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).
.collapse('show')
Shows a collapsible element.
Returns to the caller before the collapsible element has actually been shown
(i.e. before the
shown.bs.collapse
event occurs).
.collapse('hide')
Hides a collapsible element.
Returns to the caller before the collapsible element has actually been hidden
(i.e. before the
hidden.bs.collapse
event occurs).
.collapse('dispose')
Destroys an element’s collapse.
Events
Bootstrap’s collapse class exposes a few events for hooking into collapse functionality.
Event Type
Description
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).
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).
$
(
'#myCollapsible'
).
on
(
'hidden.bs.collapse'
,
function
()
{
// do something…
}) |
| Markdown | [Skip to main content](https://getbootstrap.com/docs/4.0/components/collapse/#content)
[There's a newer version of Bootstrap\!](https://getbootstrap.com/)
- [Home](https://getbootstrap.com/)
- [Documentation](https://getbootstrap.com/docs/4.0/getting-started/introduction/)
- [Examples](https://getbootstrap.com/docs/4.0/examples/)
- [Expo](https://expo.getbootstrap.com/)
- [Blog](https://blog.getbootstrap.com/)
- [v4.0](https://getbootstrap.com/docs/4.0/components/collapse/)
[Latest (v4.1.x)](https://getbootstrap.com/docs/4.1/) [v4.0.0](https://getbootstrap.com/docs/4.0/)
[v4 Alpha 6](https://v4-alpha.getbootstrap.com/) [v3.3.7](https://getbootstrap.com/docs/3.3/) [v2.3.2](https://getbootstrap.com/2.3.2/)
[Download](https://github.com/twbs/bootstrap/archive/v4.0.0.zip)
[Getting started](https://getbootstrap.com/docs/4.0/getting-started/introduction/)
- [Introduction](https://getbootstrap.com/docs/4.0/getting-started/introduction/)
- [Download](https://getbootstrap.com/docs/4.0/getting-started/download/)
- [Contents](https://getbootstrap.com/docs/4.0/getting-started/contents/)
- [Browsers & devices](https://getbootstrap.com/docs/4.0/getting-started/browsers-devices/)
- [JavaScript](https://getbootstrap.com/docs/4.0/getting-started/javascript/)
- [Theming](https://getbootstrap.com/docs/4.0/getting-started/theming/)
- [Build tools](https://getbootstrap.com/docs/4.0/getting-started/build-tools/)
- [Webpack](https://getbootstrap.com/docs/4.0/getting-started/webpack/)
- [Accessibility](https://getbootstrap.com/docs/4.0/getting-started/accessibility/)
[Layout](https://getbootstrap.com/docs/4.0/layout/overview/)
- [Overview](https://getbootstrap.com/docs/4.0/layout/overview/)
- [Grid](https://getbootstrap.com/docs/4.0/layout/grid/)
- [Media object](https://getbootstrap.com/docs/4.0/layout/media-object/)
- [Utilities for layout](https://getbootstrap.com/docs/4.0/layout/utilities-for-layout/)
[Content](https://getbootstrap.com/docs/4.0/content/reboot/)
- [Reboot](https://getbootstrap.com/docs/4.0/content/reboot/)
- [Typography](https://getbootstrap.com/docs/4.0/content/typography/)
- [Code](https://getbootstrap.com/docs/4.0/content/code/)
- [Images](https://getbootstrap.com/docs/4.0/content/images/)
- [Tables](https://getbootstrap.com/docs/4.0/content/tables/)
- [Figures](https://getbootstrap.com/docs/4.0/content/figures/)
[Components](https://getbootstrap.com/docs/4.0/components/alerts/)
- [Alerts](https://getbootstrap.com/docs/4.0/components/alerts/)
- [Badge](https://getbootstrap.com/docs/4.0/components/badge/)
- [Breadcrumb](https://getbootstrap.com/docs/4.0/components/breadcrumb/)
- [Buttons](https://getbootstrap.com/docs/4.0/components/buttons/)
- [Button group](https://getbootstrap.com/docs/4.0/components/button-group/)
- [Card](https://getbootstrap.com/docs/4.0/components/card/)
- [Carousel](https://getbootstrap.com/docs/4.0/components/carousel/)
- [Collapse](https://getbootstrap.com/docs/4.0/components/collapse/)
- [Dropdowns](https://getbootstrap.com/docs/4.0/components/dropdowns/)
- [Forms](https://getbootstrap.com/docs/4.0/components/forms/)
- [Input group](https://getbootstrap.com/docs/4.0/components/input-group/)
- [Jumbotron](https://getbootstrap.com/docs/4.0/components/jumbotron/)
- [List group](https://getbootstrap.com/docs/4.0/components/list-group/)
- [Modal](https://getbootstrap.com/docs/4.0/components/modal/)
- [Navs](https://getbootstrap.com/docs/4.0/components/navs/)
- [Navbar](https://getbootstrap.com/docs/4.0/components/navbar/)
- [Pagination](https://getbootstrap.com/docs/4.0/components/pagination/)
- [Popovers](https://getbootstrap.com/docs/4.0/components/popovers/)
- [Progress](https://getbootstrap.com/docs/4.0/components/progress/)
- [Scrollspy](https://getbootstrap.com/docs/4.0/components/scrollspy/)
- [Tooltips](https://getbootstrap.com/docs/4.0/components/tooltips/)
[Utilities](https://getbootstrap.com/docs/4.0/utilities/borders/)
- [Borders](https://getbootstrap.com/docs/4.0/utilities/borders/)
- [Clearfix](https://getbootstrap.com/docs/4.0/utilities/clearfix/)
- [Close icon](https://getbootstrap.com/docs/4.0/utilities/close-icon/)
- [Colors](https://getbootstrap.com/docs/4.0/utilities/colors/)
- [Display](https://getbootstrap.com/docs/4.0/utilities/display/)
- [Embed](https://getbootstrap.com/docs/4.0/utilities/embed/)
- [Flex](https://getbootstrap.com/docs/4.0/utilities/flex/)
- [Float](https://getbootstrap.com/docs/4.0/utilities/float/)
- [Image replacement](https://getbootstrap.com/docs/4.0/utilities/image-replacement/)
- [Position](https://getbootstrap.com/docs/4.0/utilities/position/)
- [Screenreaders](https://getbootstrap.com/docs/4.0/utilities/screenreaders/)
- [Sizing](https://getbootstrap.com/docs/4.0/utilities/sizing/)
- [Spacing](https://getbootstrap.com/docs/4.0/utilities/spacing/)
- [Text](https://getbootstrap.com/docs/4.0/utilities/text/)
- [Vertical align](https://getbootstrap.com/docs/4.0/utilities/vertical-align/)
- [Visibility](https://getbootstrap.com/docs/4.0/utilities/visibility/)
[Extend](https://getbootstrap.com/docs/4.0/extend/approach/)
- [Approach](https://getbootstrap.com/docs/4.0/extend/approach/)
- [Icons](https://getbootstrap.com/docs/4.0/extend/icons/)
[Migration](https://getbootstrap.com/docs/4.0/migration/)
[About](https://getbootstrap.com/docs/4.0/about/overview/)
- [Overview](https://getbootstrap.com/docs/4.0/about/overview/)
- [Brand](https://getbootstrap.com/docs/4.0/about/brand/)
- [License](https://getbootstrap.com/docs/4.0/about/license/)
- [Translations](https://getbootstrap.com/docs/4.0/about/translations/)
- [Example](https://getbootstrap.com/docs/4.0/components/collapse/#example)
- [Multiple targets](https://getbootstrap.com/docs/4.0/components/collapse/#multiple-targets)
- [Accordion example](https://getbootstrap.com/docs/4.0/components/collapse/#accordion-example)
- [Accessibility](https://getbootstrap.com/docs/4.0/components/collapse/#accessibility)
- [Usage](https://getbootstrap.com/docs/4.0/components/collapse/#usage)
- [Via data attributes](https://getbootstrap.com/docs/4.0/components/collapse/#via-data-attributes)
- [Via JavaScript](https://getbootstrap.com/docs/4.0/components/collapse/#via-javascript)
- [Options](https://getbootstrap.com/docs/4.0/components/collapse/#options)
- [Methods](https://getbootstrap.com/docs/4.0/components/collapse/#methods)
- [Asynchronous methods and transitions](https://getbootstrap.com/docs/4.0/components/collapse/#asynchronous-methods-and-transitions)
- [.collapse(options)](https://getbootstrap.com/docs/4.0/components/collapse/#collapseoptions)
- [.collapse('toggle')](https://getbootstrap.com/docs/4.0/components/collapse/#collapsetoggle)
- [.collapse('show')](https://getbootstrap.com/docs/4.0/components/collapse/#collapseshow)
- [.collapse('hide')](https://getbootstrap.com/docs/4.0/components/collapse/#collapsehide)
- [.collapse('dispose')](https://getbootstrap.com/docs/4.0/components/collapse/#collapsedispose)
- [Events](https://getbootstrap.com/docs/4.0/components/collapse/#events)
# Collapse
Toggle the visibility of content across your project with a few classes and our JavaScript plugins.
## 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.
[Link with href](https://getbootstrap.com/docs/4.0/components/collapse/#collapseExample) Button with data-target
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.
Copy
```
<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
[Toggle first element](https://getbootstrap.com/docs/4.0/components/collapse/#multiCollapseExample1) Toggle second element Toggle both elements
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.
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.
Copy
```
<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](https://getbootstrap.com/docs/4.0/components/card/) component, you can extend the default collapse behavior to create an accordion.
##### Collapsible Group Item \#1
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
##### Collapsible Group Item \#2
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
##### Collapsible Group Item \#3
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
Copy
```
<div id="accordion">
<div class="card">
<div class="card-header" id="headingOne">
<h5 class="mb-0">
<button class="btn btn-link" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
Collapsible Group Item #1
</button>
</h5>
</div>
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
<div class="card-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
<div class="card">
<div class="card-header" id="headingTwo">
<h5 class="mb-0">
<button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
Collapsible Group Item #2
</button>
</h5>
</div>
<div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordion">
<div class="card-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
<div class="card">
<div class="card-header" id="headingThree">
<h5 class="mb-0">
<button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
Collapsible Group Item #3
</button>
</h5>
</div>
<div id="collapseThree" class="collapse" aria-labelledby="headingThree" data-parent="#accordion">
<div class="card-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
</div>
```
## Accessibility
Be sure to add `aria-expanded` to the control element. This attribute explicitly conveys the current state of the collapsible element tied to the control to screen readers and similar assistive technologies. If the collapsible element is closed by default, the attribute on the control element should have a value of `aria-expanded="false"`. If you’ve set the collapsible element to be open by default using the `show` class, set `aria-expanded="true"` on the control instead. The plugin will automatically toggle this attribute on the control based on whether or not the collapsible element has been opened or closed (via JavaScript, or because the user triggered another control element also tied to the same collapsbile element). If the control element’s HTML element is not a button (e.g., an `<a>` or `<div>`), the attribute `role="button"` should be added to the element.
If your control element is targeting a single collapsible element – i.e. the `data-target` attribute is pointing to an `id` selector – you should add the `aria-controls` attribute to the control element, containing the `id` of the collapsible element. Modern screen readers and similar assistive technologies make use of this attribute to provide users with additional shortcuts to navigate directly to the collapsible element itself.
Note that Bootstrap’s current implementation does not cover the various keyboard interactions described in the [WAI-ARIA Authoring Practices 1.1 accordion pattern](https://www.w3.org/TR/wai-aria-practices-1.1/#accordion) - you will need to include these yourself with custom JavaScript.
## 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-toggle="collapse"` and a `data-target` to the element to automatically assign control of one or more collapsible elements. The `data-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-like group management to a collapsible area, add the data attribute `data-parent="#selector"`. Refer to the demo to see this in action.
### Via JavaScript
Enable manually with:
Copy
```
$('.collapse').collapse()
```
### Options
Options can be passed via data attributes or JavaScript. For data attributes, append the option name to `data-`, as in `data-parent=""`.
| Name | Type | Default | Description |
|---|---|---|---|
| parent | selector \| jQuery object \| DOM element | false | 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
#### Asynchronous methods and transitions
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**.
[See our JavaScript documentation for more information.](https://getbootstrap.com/docs/4.0/getting-started/javascript/)
#### `.collapse(options)`
Activates your content as a collapsible element. Accepts an optional options `object`.
Copy
```
$('#myCollapsible').collapse({
toggle: false
})
```
#### `.collapse('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).
#### `.collapse('show')`
Shows a collapsible element. **Returns to the caller before the collapsible element has actually been shown** (i.e. before the `shown.bs.collapse` event occurs).
#### `.collapse('hide')`
Hides a collapsible element. **Returns to the caller before the collapsible element has actually been hidden** (i.e. before the `hidden.bs.collapse` event occurs).
#### `.collapse('dispose')`
Destroys an element’s collapse.
### Events
Bootstrap’s collapse class exposes a few events for hooking into collapse functionality.
| Event Type | Description |
|---|---|
| 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). |
| 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). |
Copy
```
$('#myCollapsible').on('hidden.bs.collapse', function () {
// do something…
})
``` |
| Readable Markdown | Toggle the visibility of content across your project with a few classes and our JavaScript plugins.
## 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.
[Link with href](https://getbootstrap.com/docs/4.0/components/collapse/#collapseExample)
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.
```
<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
[Toggle first element](https://getbootstrap.com/docs/4.0/components/collapse/#multiCollapseExample1)
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.
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.
```
<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](https://getbootstrap.com/docs/4.0/components/card/) component, you can extend the default collapse behavior to create an accordion.
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
```
<div id="accordion">
<div class="card">
<div class="card-header" id="headingOne">
<h5 class="mb-0">
<button class="btn btn-link" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
Collapsible Group Item #1
</button>
</h5>
</div>
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
<div class="card-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
<div class="card">
<div class="card-header" id="headingTwo">
<h5 class="mb-0">
<button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
Collapsible Group Item #2
</button>
</h5>
</div>
<div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordion">
<div class="card-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
<div class="card">
<div class="card-header" id="headingThree">
<h5 class="mb-0">
<button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
Collapsible Group Item #3
</button>
</h5>
</div>
<div id="collapseThree" class="collapse" aria-labelledby="headingThree" data-parent="#accordion">
<div class="card-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
</div>
```
## Accessibility
Be sure to add `aria-expanded` to the control element. This attribute explicitly conveys the current state of the collapsible element tied to the control to screen readers and similar assistive technologies. If the collapsible element is closed by default, the attribute on the control element should have a value of `aria-expanded="false"`. If you’ve set the collapsible element to be open by default using the `show` class, set `aria-expanded="true"` on the control instead. The plugin will automatically toggle this attribute on the control based on whether or not the collapsible element has been opened or closed (via JavaScript, or because the user triggered another control element also tied to the same collapsbile element). If the control element’s HTML element is not a button (e.g., an `<a>` or `<div>`), the attribute `role="button"` should be added to the element.
If your control element is targeting a single collapsible element – i.e. the `data-target` attribute is pointing to an `id` selector – you should add the `aria-controls` attribute to the control element, containing the `id` of the collapsible element. Modern screen readers and similar assistive technologies make use of this attribute to provide users with additional shortcuts to navigate directly to the collapsible element itself.
Note that Bootstrap’s current implementation does not cover the various keyboard interactions described in the [WAI-ARIA Authoring Practices 1.1 accordion pattern](https://www.w3.org/TR/wai-aria-practices-1.1/#accordion) - you will need to include these yourself with custom JavaScript.
## 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-toggle="collapse"` and a `data-target` to the element to automatically assign control of one or more collapsible elements. The `data-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-like group management to a collapsible area, add the data attribute `data-parent="#selector"`. Refer to the demo to see this in action.
### Via JavaScript
Enable manually with:
```
$('.collapse').collapse()
```
### Options
Options can be passed via data attributes or JavaScript. For data attributes, append the option name to `data-`, as in `data-parent=""`.
| Name | Type | Default | Description |
|---|---|---|---|
| parent | selector \| jQuery object \| DOM element | false | 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
#### Asynchronous methods and transitions
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**.
[See our JavaScript documentation for more information.](https://getbootstrap.com/docs/4.0/getting-started/javascript/)
#### `.collapse(options)`
Activates your content as a collapsible element. Accepts an optional options `object`.
```
$('#myCollapsible').collapse({
toggle: false
})
```
#### `.collapse('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).
#### `.collapse('show')`
Shows a collapsible element. **Returns to the caller before the collapsible element has actually been shown** (i.e. before the `shown.bs.collapse` event occurs).
#### `.collapse('hide')`
Hides a collapsible element. **Returns to the caller before the collapsible element has actually been hidden** (i.e. before the `hidden.bs.collapse` event occurs).
#### `.collapse('dispose')`
Destroys an element’s collapse.
### Events
Bootstrap’s collapse class exposes a few events for hooking into collapse functionality.
| Event Type | Description |
|---|---|
| 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). |
| 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). |
```
$('#myCollapsible').on('hidden.bs.collapse', function () {
// do something…
})
``` |
| Shard | 92 (laksa) |
| Root Hash | 4088328555173515292 |
| Unparsed URL | com,getbootstrap!/docs/4.0/components/collapse/ s443 |