In this Bootstrap 4 tutorial, you will learn how to use the bootstrap button group component. To create button groups just wrap a series of buttons with .btn class in an <div> element and apply the class .btn-group on it. These bootstrap button groups allow you to group buttons together, either vertically or horizontally.
Horizontal Button Group:
For horizontally arrange button groups simply use .btn-group class in an <div> element. The horizontally arrange button are by default but if we want the vertically arrange group then need to use .btn-group-vertical.
Example:
<div class="btn-group">
<button type="button" class="btn btn-warning"> Home </button>
<button type="button" class="btn btn-warning"> About Us </button>
<button type="button" class="btn btn-warning"> Contact Us </button>
If you want the button size larger or smaller then directly use button group sizing classes instead of using button sizing classes to every button in a group. for example .btn-group-lg or .btn-group-sm classes to each .btn-group element to create larger or smaller button group. If you omitting these classes then the button group is the default size.
Example:
<div class="btn-group btn-group-lg mb-2">
<button type="button" class="btn btn-warning"> Home </button>
<button type="button" class="btn btn-warning"> About Us </button>
<button type="button" class="btn btn-warning"> Contact Us </button>
</div>
<div class="btn-group mb-2">
<button type="button" class="btn btn-warning"> Home </button>
<button type="button" class="btn btn-warning"> About Us </button>
<button type="button" class="btn btn-warning"> Contact Us </button>
</div>
<div class="btn-group btn-group-sm">
<button type="button" class="btn btn-warning"> Home </button>
<button type="button" class="btn btn-warning"> About Us </button>
<button type="button" class="btn btn-warning"> Contact Us </button>
In this Bootstrap 4 tutorial, you can also learn how to combine sets of button groups into the single toolbar. To do this, just wrap sets of button groups in an <div> element and apply the class .btn-toolbar on it.
Example:
<div class="btn-toolbar" role="toolbar">
<div class="btn-group mr-2">
<button type="button" class="btn btn-warning"> Home </button>
<button type="button" class="btn btn-warning"> About Us </button>
<button type="button" class="btn btn-warning"> Contact Us </button>
</div>
<div class="btn-group">
<button type="button" class="btn btn-warning"> Home </button>
<button type="button" class="btn btn-warning"> About Us </button>
For an equal length button and full-width button group, use flex utility class .d-flex to the .btn-group element. The below example shows how to use flex class.
Example:
<div class="btn-group d-flex">
<button type="button" class="btn btn-warning"> Home </button>
<button type="button" class="btn btn-warning"> About Us </button>
<button type="button" class="btn btn-warning"> Contact Us </button>
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok