Bootstrap 5 - Button group

Button group is a series of buttons together on a single line

<div class="btn-group" role="group">
  <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>

Active class

<div class="btn-group">
    <a href="#" class="btn btn-primary active">Active link
    <a href="#" class="btn btn-primary">Link
    <a href="#" class="btn btn-primary">Link
</div>

Mixed styles

<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>

Button Outlined styles

<div class="btn-group" role="group">
    <button type="button" class="btn btn-outline-primary">Left
    <button type="button" class="btn btn-outline-primary">Middle
    <button type="button" class="btn btn-outline-primary">Right
</div>

Button toolbar

Button can be added without background colors, Replace the default modifier classes with the .btn-outline-* ones to remove all background images and colors on any button.

<div class="btn-toolbar" role="toolbar">
  <div class="btn-group me-2" role="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">
    <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">
    <button type="button" class="btn btn-info">8</button>
  </div>
</div>

Button Sizes

Instead of applying button sizing classes to every button in a group, just add .btn-group-* to each .btn-group

<div class="btn-group btn-group-lg" role="group" aria-label="...">...</div>
<div class="btn-group" role="group" aria-label="...">...</div>
<div class="btn-group btn-group-sm" role="group" aria-label="...">...</div>

Button Vertical variation

Make a set of buttons appear vertically stacked rather than horizontally.

<div class="btn-group-vertical">
    <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>