Skip to content

Button group ​

Joins related buttons into one control, horizontally or vertically.

Installation ​

bash
npx bootcn add button-group
bash
pnpm dlx bootcn add button-group
bash
yarn dlx bootcn add button-group
bash
bunx --bun bootcn add button-group

The CLI also installs the design tokens and these components: button. It prints the <link> and <script> tags to add to your layout.

Usage ​

Wrap buttons in Bootstrap's .btn-group (or .btn-group-vertical) with role="group" and an aria-label that names the set.

Accessibility ​

  • role="group" and a label tell screen readers the buttons belong together.
  • Each button keeps its own name; tab order follows the visual order.

Dependencies ​

  • Bootstrap 5.3+ CSS.
  • themes/tokens/tokens.css.
  • The button component.

Source ​

The exact files the CLI installs (button-group@1.0.0). View on GitHub · Report an issue

html
<div class="btn-group bootcn-button-group" role="group" aria-label="Archive actions">
  <button type="button" class="btn bootcn-button bootcn-button--outline">Archive</button>
  <button type="button" class="btn bootcn-button bootcn-button--outline">Report</button>
  <button type="button" class="btn bootcn-button bootcn-button--outline">Snooze</button>
</div>

<div class="btn-group-vertical bootcn-button-group mt-3" role="group" aria-label="Zoom">
  <button type="button" class="btn bootcn-button bootcn-button--outline">Zoom in</button>
  <button type="button" class="btn bootcn-button bootcn-button--outline">Zoom out</button>
</div>
css
/* One shadow for the whole group; Bootstrap joins the borders and corners. */
.bootcn-button-group {
  border-radius: var(--bootcn-radius);
  box-shadow: var(--bootcn-shadow-sm);
}

.bootcn-button-group > .bootcn-button {
  box-shadow: none;
}

Released under the MIT License. Not affiliated with Bootstrap or shadcn/ui.