Skip to content

Split Button Dropdown

Bootstrap 5 split buttons: a primary deploy action whose target is chosen from an attached dropdown, plus compact save and export split buttons.

Also known as: split button, button with dropdown menu, dropdown action button, split dropdown button group

Split Button Dropdown live demo

Open in new tab

Bootstrap 5 code (HTML, CSS, JS)

A set of Bootstrap 5 split button dropdowns: a large primary action whose target is picked from an attached menu, and compact secondary split buttons for save and export actions. Use the pattern in toolbars, release dashboards, editors and admin panels where one action is common and a few related actions should stay one click away.

How it works

Everything sits in a white .sbd-card inside the .sbd-demo background. Each split button is a Bootstrap btn-group with two buttons: the main action (.sbd-main) and a narrow dropdown-toggle-split button with data-bs-toggle="dropdown". Bootstrap's own bundle opens the dropdown-menu, positions it with Popper and handles arrow keys and Escape. The colors come from overriding Bootstrap's --bs-btn-* variables in .sbd-btn and .sbd-ghost, and the menu look from --bs-dropdown-* variables in .sbd-menu.

The large split button has data-sbd-mode="select". Its menu items (.sbd-option) are rich two-line entries with an icon, a description and a check mark. The script runs on DOMContentLoaded for every .sbd-card. Clicking an option moves the active class and aria-current, copies data-sbd-value into the main button's data-sbd-target, swaps the label and the icon from data-sbd-icon, and returns focus to the main button. Clicking the main button marks it busy with aria-disabled and .is-busy, then reports "Deployed to Staging successfully." in .sbd-status after a simulated delay.

The smaller split buttons use data-sbd-mode="action": the main button and every menu item carry a data-sbd-message, which is written to the status line when clicked. The export group adds Bootstrap's dropup class so its menu opens upwards.

Customization

  • --sbd-accent and --sbd-accent-dark in .sbd-demo: change the primary button, menu icons, check marks and focus outlines in one place.
  • Add another li with a .sbd-option and its own data-sbd-value and data-sbd-icon: a new deploy target appears and works without script changes.
  • data-sbd-message on any item in a data-sbd-mode="action" group: sets the confirmation text for that action.
  • dropdown-menu-end on the first menu: remove it to align the menu with the left edge of the group.
  • max-width: 440px in .sbd-card: widen the card for longer button labels.
  • The window.setTimeout in the main button handler in script.js: replace it with a fetch() call to your own API.
  • .sbd-danger: apply it to any destructive menu item to color it red.

Use cases

  • Release dashboards: a primary deploy button lets engineers pick the target environment from an attached menu
  • Editors: a compact save split button offers related actions like save as without extra toolbar clutter
  • Admin panels: an export split button opens its menu upwards with format choices
  • Toolbars: one common action stays one click away while destructive items are colored red in the menu

Accessibility

Every toggle contains visually-hidden text such as "More deploy targets", and Bootstrap manages aria-expanded on it. Each btn-group has role="group" and an aria-label. The selected target is marked with aria-current="true" as well as a visible check, and decorative icons are aria-hidden. The busy state uses aria-disabled instead of disabled, so keyboard focus is not lost. .sbd-status is a polite live region, and all buttons and menu items have a clear 2px focus outline.

Usage notes

Requires Bootstrap 5 with its JavaScript bundle (added automatically) and Bootstrap Icons. Several cards can share a page because the script queries inside each .sbd-card.

Split Button Dropdown at a glance

Framework
Bootstrap 5
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Bootstrap 5, Bootstrap Icons
Layout
Responsive, works on mobile
Category
Button Groups
License
Free for personal and commercial use

Questions about this template

Can I use the Split Button Dropdown code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load Bootstrap 5 and Bootstrap Icons from a CDN (the links are under Requirements). Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
  • <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
Split Button Dropdown – Bootstrap 5 button groups component screenshot
Split Button Dropdown · Bootstrap 5 Button Groups

More Button Groups

Editor Button Toolbar – Bootstrap 5 button groups preview

Editor Button Toolbar

Dark Bootstrap 5 text editor toolbar with grouped icon buttons, toggle states, a block style dropdown, arrow key navigation and a working editable area.

Segmented Control – Tailwind CSS button groups preview

Segmented Control

Tailwind CSS segmented control with a sliding thumb, built on native radio inputs for single-choice view, range and billing toggles.