Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk3 min

Add Plus and Minus Icons to a Bootstrap Accordion

Use Bootstrap 5.3 Collapse markup and CSS to replace the default accordion chevron with a plus when closed and a minus when open.

Free tools Windows power users keep installed

One-click scans. No signup required.

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

Bootstrap’s accordion behavior comes from its Collapse plugin; the plus and minus signs are a visual customization. The example below uses Bootstrap 5.3 markup and CSS, with each button linked to its panel through Bootstrap data attributes. “V17” is not identified as a Bootstrap release in the available documentation, so this tutorial does not treat it as a version number.

Build the accordion with Bootstrap 5.3 markup

Bootstrap 5.3’s accordion uses an .accordion container, an .accordion-item for each entry, and a button that controls a collapsible panel. The button’s data-bs-target must match the panel’s ID. Bootstrap documents this structure in its Accordion component documentation.

As an Amazon Associate I earn from qualifying purchases.

<div class="accordion" id="helpAccordion">
  <div class="accordion-item">
    <h2 class="accordion-header" id="headingOne">
      <button class="accordion-button collapsed" type="button"
        data-bs-toggle="collapse" data-bs-target="#panelOne"
        aria-expanded="false" aria-controls="panelOne">
        How does the accordion work?
        <span class="pm-icon" aria-hidden="true"></span>
      </button>
    </h2>
    <div id="panelOne" class="accordion-collapse collapse"
      aria-labelledby="headingOne" data-bs-parent="#helpAccordion">
      <div class="accordion-body">
        Bootstrap’s Collapse plugin expands and collapses this panel.
      </div>
    </div>
  </div>

  <div class="accordion-item">
    <h2 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">
        Can more than one panel stay open?
        <span class="pm-icon" aria-hidden="true"></span>
      </button>
    </h2>
    <div id="panelTwo" class="accordion-collapse collapse"
      aria-labelledby="headingTwo" data-bs-parent="#helpAccordion">
      <div class="accordion-body">
        With this parent setting, opening a panel closes the other panel in the same group.
      </div>
    </div>
  </div>
</div>

Include Bootstrap 5.3’s CSS and JavaScript bundle in the page for the component styling and Collapse behavior. The sample’s data-bs-parent="#helpAccordion" makes the panels a mutually exclusive group: opening one closes another. To allow multiple panels to remain open, omit that attribute from the collapsible panels; Bootstrap documents both grouping and a stay-open example.

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

Style the closed and open indicators

Bootstrap 5.3 normally displays a chevron indicator. The following CSS hides that built-in background icon and draws a plus sign with two pseudo-elements. When Bootstrap removes .collapsed from the expanded button, the vertical stroke disappears, leaving a minus sign.

.accordion-button::after {
  background-image: none;
  width: 1rem;
  height: 1rem;
  margin-left: auto;
}

.accordion-button .pm-icon {
  position: relative;
  flex: 0 0 1rem;
  width: 1rem;
  height: 1rem;
  margin-left: auto;
}

.accordion-button .pm-icon::before,
.accordion-button .pm-icon::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0.75rem;
  height: 2px;
  background: currentColor;
  transform: translate(-50%, -50%);
}

.accordion-button .pm-icon::after {
  transform: translate(-50%, -50%) rotate(90deg);
  transition: transform 0.15s ease-in-out;
}

.accordion-button:not(.collapsed) .pm-icon::after {
  transform: translate(-50%, -50%) rotate(0);
}

The icon span is marked aria-hidden="true" because it is decorative; the button’s text names the action. The selector .accordion-button:not(.collapsed) follows Bootstrap 5.3’s state class, so the icon reflects the same expanded state as the Collapse panel.

Keep initial state and accessibility attributes in sync

For a panel that starts closed, as in the sample, use .collapsed on the button, aria-expanded="false", and .collapse without .show on the panel. For one that starts open, change all three together: remove .collapsed from its button, set aria-expanded="true", and add .show to its panel. Bootstrap 5.3 documents these initial-state conventions. If only one is changed, the visual indicator, accessibility state, and displayed panel may disagree.

  • Give every panel a unique ID, and use that exact ID in its button’s data-bs-target and aria-controls.
  • Keep the button’s aria-expanded value aligned with whether its panel is open.
  • Use a real button element as the trigger, and retain visible text so the control is understandable without its icon.
  • Check keyboard operation in the Bootstrap version and project configuration you ship; do not assume every optional interaction in the ARIA accordion pattern is provided automatically.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Account for Bootstrap version differences

This code uses Bootstrap 5.3 conventions, including data-bs-toggle and data-bs-target. Do not copy those attributes into a Bootstrap 4 page unchanged: Bootstrap’s version-specific documentation should guide the markup and behavior for the version actually installed. Bootstrap 5.2 added local CSS variables for accordion customization while retaining Sass customization options; the default indicator remains a chevron unless you customize it. See the Bootstrap 5.2 accordion documentation for that version’s options.

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

Bootstrap 4.0’s Collapse documentation notes that its implementation does not cover every optional keyboard interaction described by the ARIA accordion pattern. If you maintain a Bootstrap 4 accordion, verify its keyboard behavior against your application’s accessibility requirements rather than assuming it matches Bootstrap 5.3.

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.

Leave a Reply

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

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
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

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.