Collapse hides and reveals content with a height transition. Triggers use data-bs-toggle="collapse" and point at a target id via data-bs-target or href. The collapsible region needs classes collapse and optionally show for default-open state.
Accordion pattern
Wrap multiple panels in accordion; each item pairs a accordion-header button with an accordion-collapse region. Set data-bs-parent on collapses so only one section opens at a time—essential for FAQ and settings screens.
Progressive enhancement
Content remains in the DOM when collapsed (unless you lazy-load). Ensure headings remain keyboard-focusable and that aria-expanded on toggles reflects state for assistive tech.
Self-check
- Which attribute links a button to the panel it opens?
- What does
data-bs-parentenforce in an accordion? - Which class keeps a collapse visible on first paint?