Button group

Source: https://getbootstrap.com/docs/6.0/components/button-group

Group a series of buttons together on a single line or stack them in a vertical column.

Examples

Wrap a series of buttons in .btn-group.

<button type="button" class="btn-solid theme-primary">Left</button>
<button type="button" class="btn-solid theme-primary">Middle</button>
<button type="button" class="btn-solid theme-primary">Right</button>

</div>`} />

Button groups require an appropriate role attribute and explicit label to ensure assistive technologies like screen readers identify buttons as grouped and announce them. Use role="group" for button groups or role="toolbar" for button toolbars. Then use aria-label or aria-labelledby to label them.

These classes can also be added to groups of links, as an alternative to the .nav navigation components.

&lt;a href="#" class="btn-solid theme-primary active" aria-current="page">Active link&lt;/a>
&lt;a href="#" class="btn-solid theme-primary">Link&lt;/a>
&lt;a href="#" class="btn-solid theme-primary">Link&lt;/a>

</div>`} />

Dividers

Add a divider between buttons by adding the .btn-group-divider class to the .btn-group. Most useful when used with buttons that have the same theme color and a solid fill.

&lt;button type="button" class="btn-solid theme-primary">Left&lt;/button>
&lt;button type="button" class="btn-solid theme-primary active">Active&lt;/button>
&lt;button type="button" class="btn-solid theme-primary">Right&lt;/button>

</div>

<div class="btn-group btn-group-divider" role="group" aria-label="Basic example"> <button type="button" class="btn-solid theme-secondary">Left</button> <button type="button" class="btn-solid theme-secondary">Right</button> </div>`} />

Works with vertical button groups, too.

&lt;button type="button" class="btn-solid theme-primary">Left&lt;/button>
&lt;button type="button" class="btn-solid theme-primary active">Active&lt;/button>
&lt;button type="button" class="btn-solid theme-primary">Right&lt;/button>

</div>

<div class="btn-group-vertical btn-group-divider" role="group" aria-label="Basic example"> <button type="button" class="btn-solid theme-secondary">Left</button> <button type="button" class="btn-solid theme-secondary">Right</button> </div>`} />

Theme variants

Ue the .theme-{color} classes to apply a theme color to a set of buttons.

&lt;button type="button" class="btn-solid theme-accent">Left&lt;/button>
&lt;button type="button" class="btn-solid theme-accent">Middle&lt;/button>
&lt;button type="button" class="btn-solid theme-accent">Right&lt;/button>

</div>`} />

You can mix and match button variants in a button group.

&lt;button type="button" class="btn-solid theme-danger">Left&lt;/button>
&lt;button type="button" class="btn-solid theme-warning">Middle&lt;/button>
&lt;button type="button" class="btn-solid theme-success">Right&lt;/button>

</div>`} />

Style variants

All button styles are supported in button groups. Mix and match with the .btn-group-divider class to add dividers between some styles or just use the button borders in others.

&lt;button type="button" class="btn-solid theme-primary">Left&lt;/button>
&lt;button type="button" class="btn-solid theme-primary">Middle&lt;/button>
&lt;button type="button" class="btn-solid theme-primary">Right&lt;/button>

</div>`} />

&lt;button type="button" class="btn-outline theme-primary">Left&lt;/button>
&lt;button type="button" class="btn-outline theme-primary">Middle&lt;/button>
&lt;button type="button" class="btn-outline theme-primary">Right&lt;/button>

</div>`} />

&lt;button type="button" class="btn-subtle theme-primary">Left&lt;/button>
&lt;button type="button" class="btn-subtle theme-primary">Middle&lt;/button>
&lt;button type="button" class="btn-subtle theme-primary">Right&lt;/button>

</div>`} />

Toggle buttons

Checkbox

Checkbox toggle buttons can be grouped together. Any or all of the buttons can be checked.

&lt;label class="btn-check btn-outline theme-primary">
  &lt;input type="checkbox" autocomplete="off">
  Check 1
&lt;/label>
&lt;label class="btn-check btn-outline theme-primary">
  &lt;input type="checkbox" autocomplete="off">
  Check 2
&lt;/label>
&lt;label class="btn-check btn-outline theme-primary">
  &lt;input type="checkbox" autocomplete="off">
  Check 3
&lt;/label>

</div>`} />

Radio

By design, radio toggle button groups can only have one button checked at a time.

&lt;label class="btn-check btn-outline theme-primary">
  &lt;input type="radio" name="btnradio" autocomplete="off" checked>
  Radio 1
&lt;/label>
&lt;label class="btn-check btn-outline theme-primary">
  &lt;input type="radio" name="btnradio" autocomplete="off">
  Radio 2
&lt;/label>
&lt;label class="btn-check btn-outline theme-primary">
  &lt;input type="radio" name="btnradio" autocomplete="off">
  Radio 3
&lt;/label>

</div>`} />

Button toolbar

Combine sets of button groups into button toolbars for more complex components. Use utility classes as needed to space out groups, buttons, and more.

&lt;div class="btn-group" role="group" aria-label="First group">
  &lt;button type="button" class="btn-solid theme-primary">1&lt;/button>
  &lt;button type="button" class="btn-solid theme-primary">2&lt;/button>
  &lt;button type="button" class="btn-solid theme-primary">3&lt;/button>
  &lt;button type="button" class="btn-solid theme-primary">4&lt;/button>
&lt;/div>
&lt;div class="btn-group" role="group" aria-label="Second group">
  &lt;button type="button" class="btn-solid theme-secondary">5&lt;/button>
  &lt;button type="button" class="btn-solid theme-secondary">6&lt;/button>
  &lt;button type="button" class="btn-solid theme-secondary">7&lt;/button>
&lt;/div>
&lt;div class="btn-group" role="group" aria-label="Third group">
  &lt;button type="button" class="btn-solid theme-info">8&lt;/button>
&lt;/div>

</div>`} />

Feel free to mix input groups with button groups in your toolbars. Similar to the example above, you’ll likely need some utilities though to space things properly.

&lt;div class="btn-group" role="group" aria-label="First group">
  &lt;button type="button" class="btn-outline theme-secondary">1&lt;/button>
  &lt;button type="button" class="btn-outline theme-secondary">2&lt;/button>
  &lt;button type="button" class="btn-outline theme-secondary">3&lt;/button>
  &lt;button type="button" class="btn-outline theme-secondary">4&lt;/button>
&lt;/div>
&lt;div class="input-group">
  &lt;div class="input-group-text" id="btnGroupAddon">@&lt;/div>
  &lt;input type="text" class="form-control" placeholder="Input group example" aria-label="Input group example" aria-describedby="btnGroupAddon">
&lt;/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-outline theme-secondary">1</button> <button type="button" class="btn-outline theme-secondary">2</button> <button type="button" class="btn-outline theme-secondary">3</button> <button type="button" class="btn-outline theme-secondary">4</button> </div> <div class="input-group"> <div class="input-group-text" id="btnGroupAddon2">@</div> <input type="text" class="form-control" placeholder="Input group example" aria-label="Input group example" aria-describedby="btnGroupAddon2"> </div> </div>`} />

Sizing

Instead of applying button sizing classes to every button in a group, just add .btn-group-* to each .btn-group, including each one when nesting multiple groups.

&lt;button type="button" class="btn-outline theme-primary">Left&lt;/button>
&lt;button type="button" class="btn-outline theme-primary">Middle&lt;/button>
&lt;button type="button" class="btn-outline theme-primary">Right&lt;/button>

</div> <div class="btn-group" role="group" aria-label="Default button group"> <button type="button" class="btn-outline theme-primary">Left</button> <button type="button" class="btn-outline theme-primary">Middle</button> <button type="button" class="btn-outline theme-primary">Right</button> </div> <div class="btn-group btn-group-sm" role="group" aria-label="Small button group"> <button type="button" class="btn-outline theme-primary">Left</button> <button type="button" class="btn-outline theme-primary">Middle</button> <button type="button" class="btn-outline theme-primary">Right</button> </div> <div class="btn-group btn-group-xs" role="group" aria-label="Extra small button group"> <button type="button" class="btn-outline theme-primary">Left</button> <button type="button" class="btn-outline theme-primary">Middle</button> <button type="button" class="btn-outline theme-primary">Right</button> </div>`} />

Nesting

Place a .btn-group within another .btn-group when you want menus mixed with a series of buttons.

&lt;button type="button" class="btn-solid theme-primary">1&lt;/button>
&lt;button type="button" class="btn-solid theme-primary">2&lt;/button>

&lt;div class="btn-group" role="group">
  &lt;button type="button" class="btn-solid theme-primary" data-bs-toggle="menu" aria-expanded="false">
    Menu
  &lt;/button>
  &lt;div class="menu">
    &lt;a class="menu-item" href="#">Menu link&lt;/a>
    &lt;a class="menu-item" href="#">Menu link&lt;/a>
  &lt;/div>
&lt;/div>

</div>`} />

Vertical variation

Make a set of buttons appear vertically stacked rather than horizontally. Split button menus are not supported here.

&lt;button type="button" class="btn-solid theme-primary">Button&lt;/button>
&lt;button type="button" class="btn-solid theme-primary">Button&lt;/button>
&lt;button type="button" class="btn-solid theme-primary">Button&lt;/button>
&lt;button type="button" class="btn-solid theme-primary">Button&lt;/button>

</div>`} />

&lt;div class="btn-group" role="group">
  &lt;button type="button" class="btn-solid theme-primary" data-bs-toggle="menu" aria-expanded="false">
    Menu
  &lt;/button>
  &lt;div class="menu">
    &lt;a class="menu-item" href="#">Menu link&lt;/a>
    &lt;a class="menu-item" href="#">Menu link&lt;/a>
  &lt;/div>
&lt;/div>
&lt;button type="button" class="btn-solid theme-primary">Button&lt;/button>
&lt;button type="button" class="btn-solid theme-primary">Button&lt;/button>
&lt;div class="btn-group" role="group">
  &lt;button type="button" class="btn-solid theme-primary" data-bs-toggle="menu" data-bs-placement="left-start" aria-expanded="false">
    Menu
  &lt;/button>
  &lt;div class="menu">
    &lt;a class="menu-item" href="#">Menu link&lt;/a>
    &lt;a class="menu-item" href="#">Menu link&lt;/a>
  &lt;/div>
&lt;/div>
&lt;div class="btn-group" role="group">
  &lt;button type="button" class="btn-solid theme-primary" data-bs-toggle="menu" data-bs-placement="right-start" aria-expanded="false">
    Menu
  &lt;/button>
  &lt;div class="menu">
    &lt;a class="menu-item" href="#">Menu link&lt;/a>
    &lt;a class="menu-item" href="#">Menu link&lt;/a>
  &lt;/div>
&lt;/div>
&lt;div class="btn-group" role="group">
  &lt;button type="button" class="btn-solid theme-primary" data-bs-toggle="menu" data-bs-placement="top-start" aria-expanded="false">
    Menu
  &lt;/button>
  &lt;div class="menu">
    &lt;a class="menu-item" href="#">Menu link&lt;/a>
    &lt;a class="menu-item" href="#">Menu link&lt;/a>
  &lt;/div>
&lt;/div>

</div>`} />

&lt;label class="btn-check btn-outline theme-danger">
  &lt;input type="radio" name="vbtn-radio" autocomplete="off" checked>
  Radio 1
&lt;/label>
&lt;label class="btn-check btn-outline theme-danger">
  &lt;input type="radio" name="vbtn-radio" autocomplete="off">
  Radio 2
&lt;/label>
&lt;label class="btn-check btn-outline theme-danger">
  &lt;input type="radio" name="vbtn-radio" autocomplete="off">
  Radio 3
&lt;/label>

</div>`} />