October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

How to Build a Bootstrap 5 Accordion: Open Panels, Defaults, and Styling

Create a Bootstrap 5 accordion, choose whether multiple panels can stay open, set an item to open by default, and customize its presentation.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Bootstrap 5’s accordion is built with its Collapse JavaScript plugin. To create one, connect each header button to a collapse panel, then choose whether opening one panel should close another. Bootstrap’s official v5.3 Accordion documentation provides the component markup and options.

“Free Account Accordion 2026” does not identify a Bootstrap account tier or a feature that changes how accordions work. The implementation below is for Bootstrap’s documented 5.3 component.

As an Amazon Associate I earn from qualifying purchases.

How to make a Bootstrap accordion

An accordion contains a wrapper, items, header buttons, and collapsible panels. Each button needs a target that matches its panel’s ID; the button’s aria-controls should name that panel as well. Bootstrap’s Collapse JavaScript handles the toggling.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

This example allows only one panel to be open at a time. Replace YOUR_BOOTSTRAP_CSS and YOUR_BOOTSTRAP_BUNDLE_JS with the paths or approved inclusion method used by your project; the bundle includes the JavaScript needed for Collapse.

<link href="YOUR_BOOTSTRAP_CSS" rel="stylesheet">

<div class="accordion" id="helpAccordion">
  <div class="accordion-item">
    <h3 class="accordion-header" id="headingOne">
      <button class="accordion-button" type="button"
        data-bs-toggle="collapse" data-bs-target="#panelOne"
        aria-expanded="true" aria-controls="panelOne">
        First question
      </button>
    </h3>
    <div id="panelOne" class="accordion-collapse collapse show"
      aria-labelledby="headingOne" data-bs-parent="#helpAccordion">
      <div class="accordion-body">Answer for the first question.</div>
    </div>
  </div>

  <div class="accordion-item">
    <h3 class="accordion-header" id="headingTwo">
      <button class="accordion-button collapsed" type="button"
        data-bs-toggle="collapse" data-bs-target="#panelTwo"
        aria-expanded="false" aria-controls="panelTwo">
        Second question
      </button>
    </h3>
    <div id="panelTwo" class="accordion-collapse collapse"
      aria-labelledby="headingTwo" data-bs-parent="#helpAccordion">
      <div class="accordion-body">Answer for the second question.</div>
    </div>
  </div>
</div>

<script src="YOUR_BOOTSTRAP_BUNDLE_JS"></script>

Keep IDs unique on the page. If you add another item, give its heading and panel their own IDs and point the button’s data-bs-target and aria-controls at that panel.

Should multiple accordion panels stay open?

One panel at a time

For mutually exclusive panels, put data-bs-parent on each .accordion-collapse and set its value to the wrapper’s ID, as in the example. Opening one item then closes another in that group.

Allow multiple open panels

To let visitors keep several panels open together, omit data-bs-parent from each collapse panel. The target and panel IDs remain connected in the same way.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How to open a panel by default

For a panel that starts open, add show to its .accordion-collapse, remove collapsed from its button, and set that button’s aria-expanded value to true. For a panel that starts closed, use class="accordion-button collapsed", aria-expanded="false", and a panel with class="accordion-collapse collapse". Keep these states aligned so the visual state and announced expanded state agree.

How to use flush styling and customize appearance

Add accordion-flush to the wrapper for an edge-to-edge look without the standard accordion’s borders and rounded corners: <div class="accordion accordion-flush" id="helpAccordion">. Bootstrap documents CSS variables on .accordion for local customization and Sass customization for broader styling; its documentation says accordion CSS-variable support was added in v5.2.0. See the Bootstrap v5.3 Accordion documentation for the available variables and examples.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Motion and accessibility details

Bootstrap says the accordion animation depends on the prefers-reduced-motion media query, so motion behavior accounts for users’ reduced-motion preferences. Keep the button’s aria-controls and the panel’s corresponding ID matched, and update aria-expanded to reflect whether the panel is open. Bootstrap’s accordion page points to Collapse accessibility documentation for further accessibility details; it does not itself enumerate a complete keyboard interaction pattern.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.