You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The accordion plugin utilizes a few classes to handle the heavy lifting:
174
+
175
+
-`.collapse` hides the content
176
+
-`.collapse.show` shows the content
177
+
-`.collapsing` is added when the transition starts, and removed when it finishes
178
+
179
+
These classes can be found in `_transitions.scss`.
180
+
181
+
### Via data attributes
182
+
183
+
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`.
184
+
185
+
To add accordion group management to a collapsible area, add the data attribute `data-bs-parent="#selector"`.
`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. |
206
+
`toggle` | boolean | `true` | Toggles the collapsible element on invocation. |
|`dispose`| Destroys an element's collapse. (Removes stored data on the DOM element) |
229
+
|`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)`. |
230
+
|`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)`. |
231
+
|`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). |
232
+
|`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). |
233
+
|`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). |
234
+
{{< /bs-table >}}
235
+
236
+
### Events
237
+
238
+
Bootstrap's collapse class exposes a few events for hooking into collapse functionality.
239
+
240
+
{{< bs-table >}}
241
+
| Event type | Description |
242
+
| --- | --- |
243
+
|`hide.bs.collapse`| This event is fired immediately when the `hide` method has been called. |
244
+
|`hidden.bs.collapse`| This event is fired when a collapse element has been hidden from the user (will wait for CSS transitions to complete). |
245
+
|`show.bs.collapse`| This event fires immediately when the `show` instance method is called. |
246
+
|`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). |
0 commit comments