Web Photo Gallery

Bootstrap Button groups grid

Intro

Inside the web pages we create we often possess a couple of attainable solutions to introduce or a several actions which in turn can be eventually gotten worrying a specific item or a topic so it would be rather practical if they had an easy and practical approach designating the controls responsible for the user taking one route or another within a compact group with wide-spread visual appeal and styling.

To manage such cases the current edition of the Bootstrap framework-- Bootstrap 4 has complete assistance to the so called Bootstrap Button groups set which in turn typically are clearly what the full name states-- sets of buttons wrapped like a one feature with all of the components within seeming almost the very same so it's easy for the website visitor to pick the right one and it's less troubling for the eye since there is no free space in between the particular elements in the group-- it appears as a individual button bar having multiple opportunities.

The ways to make use of the Bootstrap Button groups form:

Setting up a button group is actually really uncomplicated-- everything you really need is simply an element together with the class

.btn-group
to wrap in your buttons. This particular generates a horizontally aligned group of buttons-- in the event that you desire a upright loaded group work with the
.btn-group-vertical
class as an alternative.

The overal size of the buttons inside of a group can possibly be universally regulated so utilizing appointing a single class to the entire group you are able to obtain either small or large buttons inside it-- simply just provide

.btn-group-sm
for small or
.btn-group-lg
class to the
.btn-group
element and all of the buttons within will get the determined sizing. Compared with the past version you just can't tell the buttons in the group to present extra small given that the
.btn-group-xs
class in no longer maintained by the Bootstrap 4 framework. You can eventually merge a handful of button groups into a toolbar just enclosing them within a
.btn-toolbar
element or nest a group within another just to put in a dropdown element in the child button group.

Simple example

Wrap a number of buttons with

.btn
within

.btn-group
.

 Simple  instance

<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>

Illustration of the Button Toolbar

Incorporate bunches of Bootstrap Button groups value right into button toolbars for more structure elements. Employ utility classes like required to space out groups, buttons, and likewise.

 Instance of the Button Toolbar
<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>

Do not hesitate to combine input groups together with button groups in your toolbars. Similar to the example aforementioned, you'll probably need certain utilities though to place features efficiently.

Example of the Button Toolbar
<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>

Measurement

Rather than employing button scale classes to each button inside a group, just add

.btn-group-*
to each
.btn-group
, featuring every one whenever nesting multiple groups

Sizing
<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>

Nesting

Set a

.btn-group
inside of one more
.btn-group
if you want dropdown menus combined with a variety of buttons. ( see post)

Nesting
<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>

Vertical version

Make a set of buttons turn up upright loaded rather than horizontally. Split button dropdowns are not actually supported here.

 Upright  variety
<div class="btn-group-vertical">
  ...
</div>

Popovers plus Tooltips

Because of the certain implementation ( and also some other elements), a bit of unique casing is necessitated for tooltips and also popovers inside button groups. You'll must define the option

container: 'body'
to stay clear of unwanted side consequences (such as the component expanding wider and/or giving up its round edges the moment the tooltip or popover is caused). ( more info)

One other issue to bear in mind

To get a dropdown button within a

.btn-group
generate an additional component coming with the exact same class within it and wrap it around a
<button>
with the
.dropdown-toggle
class,
data-toggle="dropdown"
and
type="button"
attributes. Next in addition to this
<button>
install a
<div>
with the class
.dropdown-menu
and create the urls of your dropdown within it ensuring you have indeed specified the
.dropdown-item
class to every one of them. That is actually the quick and very simple solution developing a dropdown inside a button group. Additionally you can easily produce a split dropdown following the same routine just mading extra ordinary button before the
.dropdown-toggle
element and clearing out the text message in it so just the tiny triangle arrow remains.

Conclusions

Generally that is simply the approach the buttons groups become created by using the most prominent mobile friendly framework in its current edition-- Bootstrap 4. These may be fairly helpful not only exhibit a couple of possible selections or a paths to take but additionally just as a additional navigation items taking place at certain places of your webpage coming with constant appearance and easing up the navigation and entire user appeal.

Look at several online video information regarding Bootstrap button groups:

Linked topics:

Bootstrap button group main documents

Bootstrap button group  formal  information

Bootstrap button group information

Bootstrap button group  short training

Establish buttons using Bootstrap v4

 Support buttons  utilizing Bootstrap v4