Throughout the web pages we build we regularly possess a couple of feasible options to expose or a number of actions which may be at some point required regarding a particular item or a topic so it would most likely be pretty practical in the case that they had an handy and straightforward solution styling the controls in charge of the user having one way or another inside of a small group with wide-spread look and styling.
To care for this type of cases the most recent edition of the Bootstrap framework-- Bootstrap 4 has whole assistance to the so called Bootstrap Button groups set which in turn commonly are precisely what the title specify-- groups of buttons enclosed as a single component together with all of the features within looking almost the same so it is really easy for the website visitor to pick out the right one and it's less troubling for the sight given that there is no free space between the certain elements in the group-- it looks as a particular button bar using numerous possibilities.
Designing a button group is certainly really easy-- everything you require is simply an element together with the class
.btn-group
.btn-group-vertical
The size of the buttons in a group can possibly be widely handled so with specifying a single class to the entire group you can get both large or small buttons in it-- just add
.btn-group-sm
.btn-group-lg
.btn-group
.btn-group-xs
.btn-toolbar
Wrap a number of buttons having
.btn
.btn-group
<div class="btn-group" role="group" aria-label="Basic example">
<button type="button" class="btn btn-secondary">Left</button>
<button type="button" class="btn btn-secondary">Middle</button>
<button type="button" class="btn btn-secondary">Right</button>
</div>
Combine packages of Bootstrap Button groups dropdown within button toolbars for more system components. Employ utility classes functioning as required to space out groups, tabs, and more.
<div class="btn-toolbar" role="toolbar" aria-label="Toolbar with button groups">
<div class="btn-group mr-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>
<button type="button" class="btn btn-secondary">4</button>
</div>
<div class="btn-group mr-2" role="group" aria-label="Second group">
<button type="button" class="btn btn-secondary">5</button>
<button type="button" class="btn btn-secondary">6</button>
<button type="button" class="btn btn-secondary">7</button>
</div>
<div class="btn-group" role="group" aria-label="Third group">
<button type="button" class="btn btn-secondary">8</button>
</div>
</div>
Don't hesitate to mix up input groups together with button groups in your toolbars. Much like the good example mentioned above, you'll most likely need some utilities though to place features effectively.
<div class="btn-toolbar mb-3" role="toolbar" aria-label="Toolbar with button groups">
<div class="btn-group mr-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>
<button type="button" class="btn btn-secondary">4</button>
</div>
<div class="input-group">
<span class="input-group-addon" id="btnGroupAddon">@</span>
<input type="text" class="form-control" placeholder="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 btn-secondary">1</button>
<button type="button" class="btn btn-secondary">2</button>
<button type="button" class="btn btn-secondary">3</button>
<button type="button" class="btn btn-secondary">4</button>
</div>
<div class="input-group">
<span class="input-group-addon" id="btnGroupAddon2">@</span>
<input type="text" class="form-control" placeholder="Input group example" aria-describedby="btnGroupAddon2">
</div>
</div>
As an alternative to employing button sizing classes to each button in a group, simply incorporate
.btn-group-*
.btn-group
<div class="btn-group btn-group-lg" role="group" aria-label="...">...</div>
<div class="btn-group" role="group" aria-label="...">...</div>
<div class="btn-group btn-group-sm" role="group" aria-label="...">...</div>
Set a
.btn-group
.btn-group
<div class="btn-group" role="group" aria-label="Button group with nested dropdown">
<button type="button" class="btn btn-secondary">1</button>
<button type="button" class="btn btn-secondary">2</button>
<div class="btn-group" role="group">
<button id="btnGroupDrop1" type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</button>
<div class="dropdown-menu" aria-labelledby="btnGroupDrop1">
<a class="dropdown-item" href="#">Dropdown link</a>
<a class="dropdown-item" href="#">Dropdown link</a>
</div>
</div>
</div>
Develop a set of buttons appear like vertically loaded as opposed to horizontally. Split button dropdowns are not assisted here.
<div class="btn-group-vertical">
...
</div>
Caused by the certain setup ( plus additional elements), a piece of significant casing is necessitated for tooltips as well as popovers within button groups. You'll ought to indicate the option
container: 'body'
In order to get a dropdown button inside a
.btn-group
<button>
.dropdown-toggle
data-toggle="dropdown"
type="button"
<button>
<div>
.dropdown-menu
.dropdown-item
.dropdown-toggle
Generally that is normally the technique the buttons groups get produced through one of the most well-known mobile friendly framework in its current version-- Bootstrap 4. These may possibly be very handy not only presenting a number of attainable selections or a paths to take but additionally just as a secondary navigation items occurring at certain places of your page having constant appeal and easing up the navigating and total user appearance.