What are button groups in Bootstrap 4?
Overview
Let’s start it with Bootstrap, the world’s most popular framework for building responsive, intellectual applications of any kind, with bootstrap CDN and predefined page templates.
Button groups
Button groups are a series of buttons on a single line, combined to show a common functionality. Wrap the <div> element with .btn-group utility class to generate a button group. Let's discuss a basic button group for now then we will elaborate on some different types.
Example
Explanation
- Lines: 3–10: We use Bootstrap
links to include Bootstrap 4 when the program is executed.CDN Content Delivery Network - Lines: 13–17: We place three
buttontags horizontally, to show a button grid. We implementclass=btn-groupon thedivtag will make it a button grid.
Vertical button groups
To change the appearance or position of buttons vertically, we can implement the btn-group-vertical utility on the div tag.
Example
Explanation
- Lines: 3–9: We use Bootstrap
links to include Bootstrap 4 at runtime.CDN Content Delivery Network - Lines: 13–17: To show grouped buttons vertically, we implement the
btn-group-verticalutility from the Bootstrap 4 packages.
Nested button groups
Nested means a similar shape will be placed inside the other. To show button groups as nested, we replicate the same code within the div container of the previous button group div.
Example
Explanation
- Lines: 3–15: We include links to include Bootstrap 4 online when the program is executed.
- Line: 18: Here, the first
divtag creates another container for the button group. - Lines: 19 and 20: We create horizontal buttons.
- Lines: 21–29: Here, the inner button group contains the
Morebutton and drops down with two options.