Bootstrap Components

Bootstrap Button Group

Intro

In the webpages we create we often have a few possible options to present or a couple of actions which can be eventually taken concerning a particular item or a topic so it would be rather useful if they had an easy and convenient way styling the controls responsible for the user taking one path or another in a compact group with universal appearance and styling.

To take care of such cases the latest version of the Bootstrap framework – Bootstrap 4 has full support to the so called button groups which generally are exactly what the name states – groups of buttons wrapped as a single element with all the elements within looking pretty much the same so it's easy for the visitor to pick the right one and it's less bothering for the eye since there is no free space between the particular elements in the group – it appears as a single button bar with multiple options.

The ways to apply the Bootstrap button group:

Creating a button group is really simple – all you need is an element with the class .btn-group to wrap your buttons. This produces a horizontally aligned group of buttons – in case you're after a vertically stacked group use the .btn-group-vertical class instead.

The size of the buttons within a group can be universally controlled so with assigning a single class to the whole group you can get either small or large buttons inside it – just add .btn-group-sm for small or .btn-group-lg class to the .btn-group element and all the buttons inside will take the defined sizing. Unlike the previous version you can't tell the buttons in the group to display extra small since the .btn-group-xs class in no longer supported by the Bootstrap 4 framework.

You can eventually combine a few button groups into a toolbar just wrapping them inside a .btn-toolbar element or nest a group inside another in order to insert a dropdown element inside the child button group.

Simple instance

Wrap a group of buttons using .btn within .btn-group.

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

Instance of the Button Toolbar

Integrate packs of button groups inside button toolbars for more complicated elements. Use utility classes functioning as demanded to space out groups, tabs, and even more.

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

Feel free to mixture input groups with button groups in your toolbars. Much like the example aforementioned, you'll very likely demand some utilities though to space items correctly.

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>

Measurements

As opposed to applying button sizing classes to every button inside a group, simply just add .btn-group-* to each and every .btn-group, featuring every one when nesting numerous groups

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

Install a .btn-group within an additional .btn-group once you wish dropdown menus combined with a series of buttons.

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 alternative

Develop a set of buttons show up upright loaded instead of horizontally. Split button dropdowns are not really maintained here.

Vertical  alternative
<div class="btn-group-vertical">
  ...
</div>

Popovers and Tooltips

Due to the certain execution ( plus a few other components), a piece of unique casing is demanded for tooltips as well as popovers within button groups. You'll need to point out the option container: 'body' to keep away from unwanted secondary effects ( like the component expanding larger and/or losing its own round edges the moment the tooltip or else popover is caused).

Yet another thing to take note of

In order to get a dropdown button inside a .btn-group create another element carrying the same class inside it and wrap it around a <button> with the

.dropdown-toggle class, data-toggle="dropdown" and type="button" attributes. Next along with this <button> place a <div> with the class .dropdown-menu and create the links of your dropdown inside it making sure you have assigned the .dropdown-item class to each one of them. That's the easy and fast way creating a dropdown inside a button group. Optionally you can create a split dropdown following the same routine just placing one more regular button before the .dropdown-toggle element and clearing out the text inside of it so only the tiny triangle arrow remains.

Final thoughts

Basically that's the way the buttons groups get created with the help of the most popular mobile friendly framework in its latest version – Bootstrap 4. These can be quite useful not only showcasing a few possible options or a paths to take but also as a secondary navigation items taking place at particular places of your page having consistent appearance ad easing up the navigation and overall user appearance.

Look at a few youtube video tutorials relating to Bootstrap button groups:

Linked topics:

Bootstrap button group formal documents

Bootstrap button group  authoritative  information

Bootstrap button group short training

Bootstrap button group  training

Establish buttons by Bootstrap v4

 Maintain buttons  utilizing Bootstrap v4

Best Free AI Website Builder

Generate AI websites with a simple prompt! Type in any language, export in zip.


AI Website Builder



Best Free Website Builder Software

Create awesome websites offline! No coding. 9900+ templates. Edit and save locally, upload wherever.


Free website builder download for Win, Mac, Linux!



Best Website Templates

HTML Business Templates

HTML Business Templates

Web Design HTML Templates

Web Design HTML Templates

HTML eCommerce Website Template

HTML eCommerce Website Template

Hotel HTML Template

Hotel HTML Template

Landing Page HTML Template

Landing Page HTML Template

Premium Design HTML Themes

Premium Design HTML Themes

HTML Resume Template

HTML Resume Template

Online Shopping HTML Template

Online Shopping HTML Template

HTML Responsive Templates

HTML Responsive Templates

Latest Posts

  1. 15 Best AI Website Creators and Generators - Generate your website instantly with AI.
  2. AI website creator and generator - how to create a website with AI in just 2 minutes.
  3. Best Free AI website generator and builder - create a website design with AI.
  4. Best Website Builder AIBest Free AI Website Builder - Create Website Design with AI
  5. Best Website Builder for Consultants, Magazines, Churches, Authors
  6. Best Website Builder for Designers, Videos, Education, Software Companies
  7. Website Builder for Beginners, Bloggers, Writers, IT Companies
  8. Best Website Builder for Restaurants, Online Stores, Real Estate, Musicians
  9. Best Website Builder for podcasts and affiliate marketing
  10. Therapists and nonprofits Website Builder
  11. Portfolio and SEO Website Builder
  12. Website Builder for Kids and Musicians
  13. Website Builder for Photographers and Artists
  14. HTML Code Generator - HTML Code Creator
  15. Web Design Program - Website Design Tool
  16. Landing Page Generator - Landing Page Builder
  17. No Coding Website Builder - Website Builder For Small Business
  18. Innovative HTML Builder Drag And Drop Free for Your Next Project
  19. Is There A Completely Free QR Code Generator
  20. Extremely Comfortable Business Website Constructor Review
  21. Bootstrap Select
  22. Bootstrap Panel
  23. Bootstrap Tabs
  24. Bootstrap Toggle
  25. Bootstrap Modal Popup
  26. Bootstrap Row
  27. Bootstrap Multiselect
  28. Bootstrap Media queries
  29. Bootstrap Login Forms
  30. Bootstrap Layout
  31. Bootstrap Jumbotron
  32. Bootstrap Breakpoints
  33. Bootstrap Navbar
  34. Bootstrap Tooltip
  35. Bootstrap Textarea
  36. Bootstrap Switch
  37. Bootstrap Slider
  38. Bootstrap Progress Bar
  39. Bootstrap Label
  40. Bootstrap Header
  41. Bootstrap Clearfix
  42. Bootstrap Sidebar
  43. Bootstrap Radio
  44. Bootstrap Offset
  45. Bootstrap Menu
  46. Bootstrap Columns
  47. Bootstrap Checkbox
  48. Bootstrap Accordion
  49. Bootstrap Image
  50. Bootstrap Grid
  51. Bootstrap Form
  52. Bootstrap Glyphicons
  53. Bootstrap List
  54. Bootstrap Carousel
  55. Bootstrap Icons
  56. Bootstrap Collapse
  57. Bootstrap Popover
  58. Bootstrap Input
  59. Bootstrap Modal
  60. Bootstrap Pagination
  61. Bootstrap Button
  62. Bootstrap Alert
  63. Bootstrap Table