Button group
Group a series of buttons on one line, stack them in a column, or combine groups in a toolbar.
Bootstrap’s button group docs describe the markup and CSS.
Example
bsButtonGroup adds .btn-group and role="group". Give each group an aria-label.
<div bsButtonGroup aria-label="Basic example">
<button type="button" bsButton theme="primary">Left</button>
<button type="button" bsButton theme="primary">Middle</button>
<button type="button" bsButton theme="primary">Right</button>
</div>Checkbox toggle buttons
Wrap a checkbox in a <label> with .btn-check and button classes to make a toggle button. The input stays in the page for keyboard and screen reader users, and the label shows the checked state.
<div bsButtonGroup aria-label="Basic checkbox toggle button group">
<label class="btn-check btn-outline theme-primary">
<input type="checkbox" checked />
Checkbox 1
</label>
<label class="btn-check btn-outline theme-primary">
<input type="checkbox" />
Checkbox 2
</label>
<label class="btn-check btn-outline theme-primary">
<input type="checkbox" />
Checkbox 3
</label>
</div>Radio toggle buttons
Use radios with a shared name so only one button in the group is selected. Add disabled to an input to disable that option.
<div class="d-flex flex-column align-items-start gap-3">
<div bsButtonGroup aria-label="Basic radio toggle button group">
<label class="btn-check btn-outline theme-primary">
<input type="radio" name="btnradio" checked />
Radio 1
</label>
<label class="btn-check btn-outline theme-primary">
<input type="radio" name="btnradio" />
Radio 2
</label>
<label class="btn-check btn-outline theme-primary">
<input type="radio" name="btnradio" />
Radio 3
</label>
</div>
<div bsButtonGroup aria-label="Radio toggle button group with a disabled option">
<label class="btn-check btn-solid theme-secondary">
<input type="radio" name="btnradio-disabled" checked />
Radio 1
</label>
<label class="btn-check btn-solid theme-secondary">
<input type="radio" name="btnradio-disabled" disabled />
Radio 2
</label>
<label class="btn-check btn-solid theme-secondary">
<input type="radio" name="btnradio-disabled" />
Radio 3
</label>
</div>
</div>Toolbar
bsButtonToolbar combines groups with role="toolbar". The left and right arrow keys, Home and End move focus between its buttons.
<div bsButtonToolbar class="gap-2" aria-label="Toolbar with button groups">
<div bsButtonGroup aria-label="First group">
<button type="button" bsButton="outline" theme="secondary">1</button>
<button type="button" bsButton="outline" theme="secondary">2</button>
<button type="button" bsButton="outline" theme="secondary">3</button>
</div>
<div bsButtonGroup aria-label="Second group">
<button type="button" bsButton="outline" theme="secondary">4</button>
<button type="button" bsButton="outline" theme="secondary">5</button>
</div>
</div>Sizing and vertical
Set size on the group instead of on every button, and add vertical to stack the buttons.
<div class="hstack gap-3 align-items-start">
<div bsButtonGroup size="lg" aria-label="Large group">
<button type="button" bsButton="outline" theme="primary">Left</button>
<button type="button" bsButton="outline" theme="primary">Right</button>
</div>
<div bsButtonGroup size="sm" aria-label="Small group">
<button type="button" bsButton="outline" theme="primary">Left</button>
<button type="button" bsButton="outline" theme="primary">Right</button>
</div>
<div bsButtonGroup vertical aria-label="Vertical group">
<button type="button" bsButton theme="secondary">Top</button>
<button type="button" bsButton theme="secondary">Middle</button>
<button type="button" bsButton theme="secondary">Bottom</button>
</div>
</div>API
BsButtonGroup
Selector: [bsButtonGroup]
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
size | 'xs' | 'sm' | 'md' | 'lg' | 'md' | Size of every button in the group. |
vertical | boolean | false | Stacks the buttons. |
BsButtonToolbar
Selector: [bsButtonToolbar]