Group related buttons into one connected control, horizontal or vertical, with toolbars, toggle inputs, and nested menus.
Introduction
Button groups join a series of buttons into one connected control. The group collapses the borders between adjacent buttons, squares their inner corners, and draws a separator between them, which shows that the actions belong together.
Basic structure
Apply the .button-group class to a container that wraps a series of .button elements. The group handles the borders, corners, and separators between the buttons.
<div class="button-group" role="group" aria-label="Basic example">
<button type="button" class="button default">Left</button>
<button type="button" class="button default">Middle</button>
<button type="button" class="button default">Right</button>
</div>
<div class="button-group" role="group" aria-label="Basic example">
<button type="button" class="button primary">Left</button>
<button type="button" class="button primary">Middle</button>
<button type="button" class="button primary">Right</button>
</div>Accessibility: Assistive technologies announce a set of buttons as a group only with the right ARIA attributes. Use role="group" on a button group or role="toolbar" on a button toolbar, and label it with aria-label or aria-labelledby.
Links with the .button class group the same way. Mark the link of the current page with .active and aria-current="page".
<div class="button-group">
<a href="#" class="button primary active" aria-current="page">Active link</a>
<a href="#" class="button primary">Link</a>
<a href="#" class="button primary">Link</a>
</div>Context variants
Each button in a group keeps its own context class, so one group can mix context colors.
<div class="button-group" role="group" aria-label="Contextual button group example">
<button type="button" class="button danger">Left</button>
<button type="button" class="button warning">Middle</button>
<button type="button" class="button success">Right</button>
</div>Style variants
The style modifiers of the button apply inside a group as they do on a single button.
Outline variant
Add .outline to each button for a group of bordered buttons with transparent backgrounds.
<div class="button-group" role="group" aria-label="Basic outline example">
<button type="button" class="button outline primary">Left</button>
<button type="button" class="button outline primary">Middle</button>
<button type="button" class="button outline primary">Right</button>
</div>Smooth variant
Add .smooth to each button for a group of buttons with subdued backgrounds.
<div class="button-group" role="group" aria-label="Basic smooth example">
<button type="button" class="button smooth primary">Left</button>
<button type="button" class="button smooth primary">Middle</button>
<button type="button" class="button smooth primary">Right</button>
</div>Form integration
A <label> with the .button and .button-check classes wraps a checkbox or radio input and renders it as a button. In a group, such labels form a selection control that looks like a button group.
Checkbox toggle buttons
Checkbox inputs make a control where several options can be selected at once.
<div class="button-group" role="group" aria-label="Checkbox toggle button group">
<label class="button button-check outline primary">
<input type="checkbox" autocomplete="off">
Checkbox 1
</label>
<label class="button button-check outline primary">
<input type="checkbox" autocomplete="off">
Checkbox 2
</label>
<label class="button button-check outline primary">
<input type="checkbox" autocomplete="off">
Checkbox 3
</label>
</div>Radio toggle buttons
Radio inputs that share a name make a control where one option is selected at a time.
<div class="button-group" role="group" aria-label="Radio toggle button group">
<label class="button button-check outline primary">
<input type="radio" name="buttonradio" autocomplete="off" checked>
Radio 1
</label>
<label class="button button-check outline primary">
<input type="radio" name="buttonradio" autocomplete="off">
Radio 2
</label>
<label class="button button-check outline primary">
<input type="radio" name="buttonradio" autocomplete="off">
Radio 3
</label>
</div>The inputs keep their native behavior and semantics: assistive technologies announce them as checkboxes and radio buttons, and they submit with a form.
Button toolbars
A button toolbar lays out several button groups, and other controls, in one wrapping row.
Basic toolbar
Wrap several .button-group elements in a .button-toolbar container, and space them with margin utilities.
<div class="button-toolbar" role="toolbar" aria-label="Toolbar with button groups">
<div class="button-group me-xs" role="group" aria-label="First group">
<button type="button" class="button primary">1</button>
<button type="button" class="button primary">2</button>
<button type="button" class="button primary">3</button>
<button type="button" class="button primary">4</button>
</div>
<div class="button-group me-xs" role="group" aria-label="Second group">
<button type="button" class="button secondary">5</button>
<button type="button" class="button secondary">6</button>
<button type="button" class="button secondary">7</button>
</div>
<div class="button-group" role="group" aria-label="Third group">
<button type="button" class="button info">8</button>
</div>
</div>Accessibility: Apply role="toolbar" to a button toolbar and describe its purpose with aria-label, so assistive technologies announce it.
With form controls
A toolbar can hold an input group next to its button groups. The input group takes its natural width inside a toolbar instead of the full width.
<div class="button-toolbar mb-md" role="toolbar" aria-label="Toolbar with button groups and input">
<div class="button-group me-xs" role="group" aria-label="Control group">
<button type="button" class="button outline secondary">1</button>
<button type="button" class="button outline secondary">2</button>
<button type="button" class="button outline secondary">3</button>
<button type="button" class="button outline secondary">4</button>
</div>
<div class="input-group">
<div class="input-addon" id="buttonGroupAddon">@</div>
<input type="text" class="form-input" placeholder="Input group example" aria-label="Input group example" aria-describedby="buttonGroupAddon">
</div>
</div>The toolbar is a flex container, so flex utilities such as .justify-content-between distribute its children.
<div class="button-toolbar justify-content-between" role="toolbar" aria-label="Toolbar with spaced elements">
<div class="button-group" role="group" aria-label="Button controls">
<button type="button" class="button outline secondary">1</button>
<button type="button" class="button outline secondary">2</button>
<button type="button" class="button outline secondary">3</button>
<button type="button" class="button outline secondary">4</button>
</div>
<div class="input-group">
<div class="input-addon" id="buttonGroupAddon2">@</div>
<input type="text" class="form-input" placeholder="Input group example" aria-label="Input group example" aria-describedby="buttonGroupAddon2">
</div>
</div>Size variants
Add .lg or .sm to the .button-group container to size all of its buttons at once, instead of sizing each button.
<div class="button-group lg" role="group" aria-label="Large button group">
<button type="button" class="button outline primary">Left</button>
<button type="button" class="button outline primary">Middle</button>
<button type="button" class="button outline primary">Right</button>
</div>
<br /><br />
<div class="button-group sm" role="group" aria-label="Small button group">
<button type="button" class="button outline primary">Left</button>
<button type="button" class="button outline primary">Middle</button>
<button type="button" class="button outline primary">Right</button>
</div>A size class applies to the direct child buttons of its group. Add it to each nested group as well.
Nesting
Place a .button-group inside another .button-group to mix a menu with a series of buttons. The inner group holds the menu toggle and its .menu.
<div class="button-group" role="group" aria-label="Button group with nested dropdown">
<button type="button" class="button primary">1</button>
<button type="button" class="button primary">2</button>
<div class="button-group" role="group">
<button type="button" class="button primary caret" data-cx-toggle="menu" aria-expanded="false">
Menu
</button>
<ul class="menu">
<li><a class="menu-item" href="#">Menu Item</a></li>
<li><a class="menu-item" href="#">Menu Item</a></li>
</ul>
</div>
</div>Vertical orientation
Use the .button-group-vertical class in place of .button-group to stack the buttons. Each button takes the full width of the group.
<div class="button-group-vertical" role="group" aria-label="Vertical button group">
<button type="button" class="button primary">Button</button>
<button type="button" class="button primary">Button</button>
<button type="button" class="button primary">Button</button>
<button type="button" class="button primary">Button</button>
</div>Vertical groups nest menus as horizontal groups do.
<div class="button-group-vertical" role="group" aria-label="Vertical button group with dropdowns">
<button type="button" class="button primary">Button</button>
<button type="button" class="button primary">Button</button>
<div class="button-group" role="group">
<button type="button" class="button primary caret" data-cx-toggle="menu" aria-expanded="false">
Menu
</button>
<ul class="menu">
<li><a class="menu-item" href="#">Menu Item</a></li>
<li><a class="menu-item" href="#">Menu Item</a></li>
</ul>
</div>
<div class="button-group" role="group">
<button type="button" class="button primary caret" data-cx-toggle="menu" aria-expanded="false">
Menu
</button>
<ul class="menu">
<li><a class="menu-item" href="#">Menu Item</a></li>
<li><a class="menu-item" href="#">Menu Item</a></li>
</ul>
</div>
</div>Checkbox and radio toggle buttons stack in a vertical group as well.
<div class="button-group-vertical" role="group" aria-label="Vertical radio toggle button group">
<label class="button button-check outline danger">
<input type="radio" name="vbutton-radio" autocomplete="off" checked>
Radio 1
</label>
<label class="button button-check outline danger">
<input type="radio" name="vbutton-radio" autocomplete="off">
Radio 2
</label>
<label class="button button-check outline danger">
<input type="radio" name="vbutton-radio" autocomplete="off">
Radio 3
</label>
</div>