Bootstrap

Bootstrap Button Groups

Mastering Bootstrap Button Groups: Organize Your Actions with Style

When you want to group multiple related buttons together on your web page, Bootstrap Button Groups provide a clean, responsive, and user-friendly way to do it. Whether it’s navigation, toggles, or grouped actions, Bootstrap makes it easy to manage button collections in a visually appealing layout.

What Are Bootstrap Button Groups?

Bootstrap Button Groups are components that group a series of buttons together on a single line, making them appear as a unified block rather than individual buttons scattered across the page. This is useful for toolbars, segmented controls, or any interface where multiple options belong together.

Creating a Basic Button Group

To create a button group, wrap your buttons inside a container with the .btn-group class:

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

This groups the three buttons horizontally with no gaps between them, visually connected by shared borders and rounded corners.

Button Toolbar

You can also group multiple button groups into a toolbar:

html
<div class="btn-toolbar" role="toolbar" aria-label="Toolbar with button groups">
<div class="btn-group me-2" role="group" aria-label="First group">
<button type="button" class="btn btn-secondary">1</button>
<button type="button" class="btn btn-secondary">2</button>
<button type="button" class="btn btn-secondary">3</button>
</div>
<div class="btn-group" role="group" aria-label="Second group">
<button type="button" class="btn btn-secondary">4</button>
<button type="button" class="btn btn-secondary">5</button>
</div>
</div>

This arranges multiple groups side by side in a toolbar format.

Vertical Button Groups

By default, button groups are horizontal, but you can stack buttons vertically by adding the .btn-group-vertical class:

html
<div class="btn-group-vertical" role="group" aria-label="Vertical button group">
<button type="button" class="btn btn-info">Top</button>
<button type="button" class="btn btn-info">Middle</button>
<button type="button" class="btn btn-info">Bottom</button>
</div>

Toggle Buttons in Groups

Bootstrap supports toggle buttons — where buttons can act like radio buttons or checkboxes. Add data-bs-toggle="buttons" and use input elements inside labels:

html
<div class="btn-group" role="group" aria-label="Toggle button group">
<input type="radio" class="btn-check" name="options" id="option1" autocomplete="off" checked>
<label class="btn btn-outline-primary" for="option1">Option 1</label>

<input type="radio" class="btn-check" name="options" id="option2" autocomplete="off">
<label class="btn btn-outline-primary" for="option2">Option 2</label>
</div>

This creates toggleable buttons with smooth UI feedback.

Why Use Button Groups?

  • Group related actions for better user experience

  • Maintain a clean and organized UI

  • Provide toggle functionality for selections

  • Responsive and accessible by default


Bootstrap Button Groups help you organize buttons logically, enhance usability, and keep your design neat. Try different configurations to fit your site’s needs!

Leave a Reply

Your email address will not be published. Required fields are marked *