Button group
Joins related buttons into one control, horizontally or vertically.
- Version 1.0.0
- Bootstrap 5.3+
- Requires Bootstrap CSS
- Source on GitHub
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>Installation
bash
npx bootcn add button-groupbash
pnpm dlx bootcn add button-groupbash
yarn dlx bootcn add button-groupbash
bunx --bun bootcn add button-groupThe CLI also installs the design tokens and these components: button. It prints the <link> and <script> tags to add to your layout.
- Load Bootstrap 5.3 (Bootstrap CSS) and the design tokens.
- Install the components it uses:
button. - Copy the files from Source into your project. With the default
bootcn.jsonthey go here:
| File | Default location |
|---|---|
button-group.html | components/ui/button-group.html |
button-group.css | assets/css/button-group.css |
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
buttoncomponent.
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;
}
