Components
Button group
Group a series of buttons on a single line, with .btn-check for checkbox and radio groups and a details element for nested dropdowns.
How it works
Button groups are pure CSS in Bootstrap and are unchanged. Two things differ in practice: toggle groups use
.btn-check inputs (as in stock Bootstrap — no plugin), and a dropdown inside a group is a
<details class="dropdown btn-group"> rather than a button plus a script.
- Baseline: flexbox,
.btn-check,<details>. - Enhancement: none needed.
- Fallback: none needed.
Basic example
Wrap buttons in .btn-group. Add role="group" and a label.
HTML
<div class="btn-group" role="group" aria-label="Basic example">
<button type="button" class="btn btn-primary">Left</button>
<button type="button" class="btn btn-primary">Middle</button>
<button type="button" class="btn btn-primary">Right</button>
</div>Links work too; give the group role="group" and the links role="button" if they act as buttons.
HTML
<div class="btn-group">
<a href="#!" class="btn btn-primary active" aria-current="page">Active link</a>
<a href="#!" class="btn btn-primary">Link</a>
<a href="#!" class="btn btn-primary">Link</a>
</div>Mixed styles
HTML
<div class="btn-group" role="group" aria-label="Basic mixed styles example">
<button type="button" class="btn btn-danger">Left</button>
<button type="button" class="btn btn-warning">Middle</button>
<button type="button" class="btn btn-success">Right</button>
</div>Outlined styles
HTML
<div class="btn-group" role="group" aria-label="Basic outlined example">
<button type="button" class="btn btn-outline-primary">Left</button>
<button type="button" class="btn btn-outline-primary">Middle</button>
<button type="button" class="btn btn-outline-primary">Right</button>
</div>HTML
<div class="btn-group" role="group" aria-label="Brand outlined example">
<button type="button" class="btn btn-outline-gold">Red corner</button>
<button type="button" class="btn btn-outline-gold">Blue corner</button>
<button type="button" class="btn btn-outline-gold">Draw</button>
</div>Checkbox and radio button groups
Put .btn-check inputs and their labels directly inside .btn-group. No script and
no data-bs-toggle="buttons"; the checked state is the input's own.
HTML
<div class="btn-group" role="group" aria-label="Basic checkbox toggle button group">
<input type="checkbox" class="btn-check" id="btngroup-check-1" autocomplete="off">
<label class="btn btn-outline-primary" for="btngroup-check-1">Checkbox 1</label>
<input type="checkbox" class="btn-check" id="btngroup-check-2" autocomplete="off">
<label class="btn btn-outline-primary" for="btngroup-check-2">Checkbox 2</label>
<input type="checkbox" class="btn-check" id="btngroup-check-3" autocomplete="off">
<label class="btn btn-outline-primary" for="btngroup-check-3">Checkbox 3</label>
</div>HTML
<div class="btn-group" role="group" aria-label="Basic radio toggle button group">
<input type="radio" class="btn-check" name="btngroup-radio" id="btngroup-radio-1" autocomplete="off" checked>
<label class="btn btn-outline-primary" for="btngroup-radio-1">Radio 1</label>
<input type="radio" class="btn-check" name="btngroup-radio" id="btngroup-radio-2" autocomplete="off">
<label class="btn btn-outline-primary" for="btngroup-radio-2">Radio 2</label>
<input type="radio" class="btn-check" name="btngroup-radio" id="btngroup-radio-3" autocomplete="off">
<label class="btn btn-outline-primary" for="btngroup-radio-3">Radio 3</label>
</div>A segmented control for the tale of the tape:
HTML
<div class="btn-group" role="group" aria-label="Weight class">
<input type="radio" class="btn-check" name="btngroup-weight" id="btngroup-weight-1" autocomplete="off" checked>
<label class="btn btn-outline-gold" for="btngroup-weight-1">Cruiserweight</label>
<input type="radio" class="btn-check" name="btngroup-weight" id="btngroup-weight-2" autocomplete="off">
<label class="btn btn-outline-gold" for="btngroup-weight-2">Heavyweight</label>
<input type="radio" class="btn-check" name="btngroup-weight" id="btngroup-weight-3" autocomplete="off">
<label class="btn btn-outline-gold" for="btngroup-weight-3">Super heavyweight</label>
</div>Button toolbar
Combine groups in a .btn-toolbar. Space them with margin utilities.
HTML
<div class="btn-toolbar" role="toolbar" aria-label="Toolbar with button groups">
<div class="btn-group me-2" role="group" aria-label="First group">
<button type="button" class="btn btn-primary">1</button>
<button type="button" class="btn btn-primary">2</button>
<button type="button" class="btn btn-primary">3</button>
<button type="button" class="btn btn-primary">4</button>
</div>
<div class="btn-group me-2" role="group" aria-label="Second group">
<button type="button" class="btn btn-secondary">5</button>
<button type="button" class="btn btn-secondary">6</button>
<button type="button" class="btn btn-secondary">7</button>
</div>
<div class="btn-group" role="group" aria-label="Third group">
<button type="button" class="btn btn-navy">8</button>
</div>
</div>Mix in an input group; it shrinks to fit inside a toolbar.
HTML
<div class="btn-toolbar mb-3" role="toolbar" aria-label="Toolbar with button groups">
<div class="btn-group me-2" role="group" aria-label="First group">
<button type="button" class="btn btn-outline-secondary">1</button>
<button type="button" class="btn btn-outline-secondary">2</button>
<button type="button" class="btn btn-outline-secondary">3</button>
<button type="button" class="btn btn-outline-secondary">4</button>
</div>
<div class="input-group">
<div class="input-group-text" id="btngroup-addon-1">@</div>
<input type="text" class="form-control" placeholder="Input group example" aria-label="Input group example" aria-describedby="btngroup-addon-1">
</div>
</div>
<div class="btn-toolbar justify-content-between" role="toolbar" aria-label="Toolbar with button groups">
<div class="btn-group" role="group" aria-label="First group">
<button type="button" class="btn btn-outline-secondary">1</button>
<button type="button" class="btn btn-outline-secondary">2</button>
<button type="button" class="btn btn-outline-secondary">3</button>
<button type="button" class="btn btn-outline-secondary">4</button>
</div>
<div class="input-group">
<div class="input-group-text" id="btngroup-addon-2">@</div>
<input type="text" class="form-control" placeholder="Input group example" aria-label="Input group example" aria-describedby="btngroup-addon-2">
</div>
</div>Sizing
Size the whole group with .btn-group-lg or .btn-group-sm instead of each button.
HTML
<div class="btn-group btn-group-lg" role="group" aria-label="Large button group">
<button type="button" class="btn btn-outline-primary">Left</button>
<button type="button" class="btn btn-outline-primary">Middle</button>
<button type="button" class="btn btn-outline-primary">Right</button>
</div>
<br>
<div class="btn-group mt-2" role="group" aria-label="Default button group">
<button type="button" class="btn btn-outline-primary">Left</button>
<button type="button" class="btn btn-outline-primary">Middle</button>
<button type="button" class="btn btn-outline-primary">Right</button>
</div>
<br>
<div class="btn-group btn-group-sm mt-2" role="group" aria-label="Small button group">
<button type="button" class="btn btn-outline-primary">Left</button>
<button type="button" class="btn btn-outline-primary">Middle</button>
<button type="button" class="btn btn-outline-primary">Right</button>
</div>Nesting
To put a dropdown in a group, nest a <details class="dropdown btn-group">. The
<summary class="btn dropdown-toggle"> is the trigger and the menu follows it. The
.btn-group class on the details is what joins the borders. See
Dropdowns for the menu options.
Dropdown
HTML
<div class="btn-group" role="group" aria-label="Button group with nested dropdown">
<button type="button" class="btn btn-primary">1</button>
<button type="button" class="btn btn-primary">2</button>
<details class="dropdown btn-group">
<summary class="btn btn-primary dropdown-toggle">Dropdown</summary>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#!">Dropdown link</a></li>
<li><a class="dropdown-item" href="#!">Dropdown link</a></li>
</ul>
</details>
</div><details> menu stays open until the summary is clicked again. For click-outside
dismissal use the popover dropdown variant from the
Dropdowns page; it does not need the group to be its parent.Vertical variation
Stack buttons with .btn-group-vertical. Split-button dropdowns are not supported here, but a nested details dropdown is.
HTML
<div class="btn-group-vertical" role="group" aria-label="Vertical button group">
<button type="button" class="btn btn-navy">Button</button>
<button type="button" class="btn btn-navy">Button</button>
<button type="button" class="btn btn-navy">Button</button>
<button type="button" class="btn btn-navy">Button</button>
</div>Dropdown
HTML
<div class="btn-group-vertical" role="group" aria-label="Vertical button group with dropdown">
<button type="button" class="btn btn-outline-gold">Button</button>
<button type="button" class="btn btn-outline-gold">Button</button>
<details class="dropdown btn-group">
<summary class="btn btn-outline-gold dropdown-toggle">Dropdown</summary>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#!">Dropdown link</a></li>
<li><a class="dropdown-item" href="#!">Dropdown link</a></li>
</ul>
</details>
</div>HTML
<div class="btn-group-vertical" role="group" aria-label="Vertical radio toggle button group">
<input type="radio" class="btn-check" name="btngroup-vradio" id="btngroup-vradio-1" autocomplete="off" checked>
<label class="btn btn-outline-danger" for="btngroup-vradio-1">Radio 1</label>
<input type="radio" class="btn-check" name="btngroup-vradio" id="btngroup-vradio-2" autocomplete="off">
<label class="btn btn-outline-danger" for="btngroup-vradio-2">Radio 2</label>
<input type="radio" class="btn-check" name="btngroup-vradio" id="btngroup-vradio-3" autocomplete="off">
<label class="btn btn-outline-danger" for="btngroup-vradio-3">Radio 3</label>
</div>Accessibility
- Groups need
role="group"(orrole="toolbar"for a toolbar) and anaria-labeloraria-labelledby; assistive technology does not infer grouping from the border. - Each
.btn-checkinput needs a uniqueidmatched by its label'sfor. Radios need a sharedname. - The nested
<summary>is a native disclosure button; noaria-expandedis needed.
CSS
No component-level variables. The group radius follows $btn-border-radius (2 px).
.btn-group { border-radius: 2px; }
.btn-group > details.dropdown { display: inline-flex; } // scss/components/_dropdown.scss