Button group

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

Layer: components
1 dependency

Examples

Wrap a series of buttons in .btn-group.

HTML
<div class="btn-group" role="group" aria-label="Basic example">
  <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.

HTML
<div class="btn-group">
  <a href="#" class="btn-solid theme-primary active" aria-current="page">Active link</a>
  <a href="#" class="btn-solid theme-primary">Link</a>
  <a href="#" class="btn-solid theme-primary">Link</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.

HTML
<div class="btn-group btn-group-divider" role="group" aria-label="Basic example">
  <button type="button" class="btn-solid theme-primary">Left</button>
  <button type="button" class="btn-solid theme-primary active">Active</button>
  <button type="button" class="btn-solid theme-primary">Right</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.

HTML
<div class="btn-group-vertical btn-group-divider" role="group" aria-label="Basic example">
  <button type="button" class="btn-solid theme-primary">Left</button>
  <button type="button" class="btn-solid theme-primary active">Active</button>
  <button type="button" class="btn-solid theme-primary">Right</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.

HTML
<div class="btn-group" role="group" aria-label="Accent theme example">
  <button type="button" class="btn-solid theme-accent">Left</button>
  <button type="button" class="btn-solid theme-accent">Middle</button>
  <button type="button" class="btn-solid theme-accent">Right</button>
</div>

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

HTML
<div class="btn-group" role="group" aria-label="Basic mixed styles example">
  <button type="button" class="btn-solid theme-danger">Left</button>
  <button type="button" class="btn-solid theme-warning">Middle</button>
  <button type="button" class="btn-solid theme-success">Right</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.

HTML
<div class="btn-group btn-group-divider" role="group" aria-label="Solid example">
  <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>
HTML
<div class="btn-group" role="group" aria-label="Outlined example">
  <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>
HTML
<div class="btn-group btn-group-divider" role="group" aria-label="Subtle example">
  <button type="button" class="btn-subtle theme-primary">Left</button>
  <button type="button" class="btn-subtle theme-primary">Middle</button>
  <button type="button" class="btn-subtle theme-primary">Right</button>
</div>

Toggle buttons

Checkbox

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

HTML
<div class="btn-group" role="group" aria-label="Basic checkbox toggle button group">
  <label class="btn-check btn-outline theme-primary">
    <input type="checkbox" autocomplete="off">
    Check 1
  </label>
  <label class="btn-check btn-outline theme-primary">
    <input type="checkbox" autocomplete="off">
    Check 2
  </label>
  <label class="btn-check btn-outline theme-primary">
    <input type="checkbox" autocomplete="off">
    Check 3
  </label>
</div>

Radio

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

HTML
<div class="btn-group" role="group" aria-label="Basic radio toggle button group">
  <label class="btn-check btn-outline theme-primary">
    <input type="radio" name="btnradio" autocomplete="off" checked>
    Radio 1
  </label>
  <label class="btn-check btn-outline theme-primary">
    <input type="radio" name="btnradio" autocomplete="off">
    Radio 2
  </label>
  <label class="btn-check btn-outline theme-primary">
    <input type="radio" name="btnradio" autocomplete="off">
    Radio 3
  </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.

HTML
<div class="btn-toolbar" role="toolbar" aria-label="Toolbar with button groups">
  <div class="btn-group" role="group" aria-label="First group">
    <button type="button" class="btn-solid theme-primary">1</button>
    <button type="button" class="btn-solid theme-primary">2</button>
    <button type="button" class="btn-solid theme-primary">3</button>
    <button type="button" class="btn-solid theme-primary">4</button>
  </div>
  <div class="btn-group" role="group" aria-label="Second group">
    <button type="button" class="btn-solid theme-secondary">5</button>
    <button type="button" class="btn-solid theme-secondary">6</button>
    <button type="button" class="btn-solid theme-secondary">7</button>
  </div>
  <div class="btn-group" role="group" aria-label="Third group">
    <button type="button" class="btn-solid theme-info">8</button>
  </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.

HTML
<div class="btn-toolbar" 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="btnGroupAddon">@</div>
    <input type="text" class="form-control" placeholder="Input group example" aria-label="Input group example" aria-describedby="btnGroupAddon">
  </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.

HTML
<div class="btn-group btn-group-lg" role="group" aria-label="Large 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" 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.

HTML
<div class="btn-group" role="group" aria-label="Button group with nested menu">
  <button type="button" class="btn-solid theme-primary">1</button>
  <button type="button" class="btn-solid theme-primary">2</button>

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

Vertical variation

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

HTML
<div class="btn-group-vertical" role="group" aria-label="Vertical button group">
  <button type="button" class="btn-solid theme-primary">Button</button>
  <button type="button" class="btn-solid theme-primary">Button</button>
  <button type="button" class="btn-solid theme-primary">Button</button>
  <button type="button" class="btn-solid theme-primary">Button</button>
</div>
HTML
<div class="btn-group-vertical" role="group" aria-label="Vertical button group">
  <div class="btn-group" role="group">
    <button type="button" class="btn-solid theme-primary" data-bs-toggle="menu" aria-expanded="false">
      Menu
    </button>
    <div class="menu">
      <a class="menu-item" href="#">Menu link</a>
      <a class="menu-item" href="#">Menu link</a>
    </div>
  </div>
  <button type="button" class="btn-solid theme-primary">Button</button>
  <button type="button" class="btn-solid theme-primary">Button</button>
  <div class="btn-group" role="group">
    <button type="button" class="btn-solid theme-primary" data-bs-toggle="menu" data-bs-placement="left-start" aria-expanded="false">
      Menu
    </button>
    <div class="menu">
      <a class="menu-item" href="#">Menu link</a>
      <a class="menu-item" href="#">Menu link</a>
    </div>
  </div>
  <div class="btn-group" role="group">
    <button type="button" class="btn-solid theme-primary" data-bs-toggle="menu" data-bs-placement="right-start" aria-expanded="false">
      Menu
    </button>
    <div class="menu">
      <a class="menu-item" href="#">Menu link</a>
      <a class="menu-item" href="#">Menu link</a>
    </div>
  </div>
  <div class="btn-group" role="group">
    <button type="button" class="btn-solid theme-primary" data-bs-toggle="menu" data-bs-placement="top-start" aria-expanded="false">
      Menu
    </button>
    <div class="menu">
      <a class="menu-item" href="#">Menu link</a>
      <a class="menu-item" href="#">Menu link</a>
    </div>
  </div>
</div>
HTML
<div class="btn-group-vertical" role="group" aria-label="Vertical radio toggle button group">
  <label class="btn-check btn-outline theme-danger">
    <input type="radio" name="vbtn-radio" autocomplete="off" checked>
    Radio 1
  </label>
  <label class="btn-check btn-outline theme-danger">
    <input type="radio" name="vbtn-radio" autocomplete="off">
    Radio 2
  </label>
  <label class="btn-check btn-outline theme-danger">
    <input type="radio" name="vbtn-radio" autocomplete="off">
    Radio 3
  </label>
</div>