Bootstrap 4 Button Group

Bootstrap 4 Button Group is a series of buttons grouped together in a single line. You can create a horizontal group button, vertical group button, button toolbar, resizing buttons, and nesting buttons with the examples given below.

Basic Button Group in Bootstrap 4

The basic button group are the set of buttons wrapped inside a <div> element. To create a basic button group, you have to use the Bootstrap 4 class .btn-group to the <div> element with the button placed inside it as given below:

Test it Live

Output

Basic Button Group in Bootstrap 4

The above example shows the 4 button items grouped together in a single line. You can add as many buttons as you want to create a button group.

Button Toolbar Using Button Group in Bootstrap 4

You can combine Bootstrap 4 button groups into a button toolbar to create more complex components. Toolbars are useful to display the navigations to other pages or page numbers to visit the pages on a website.

To create a button toolbar, you need to add the Bootstrap 4 class .btn-toolbar to the <div> element with the group buttons placed inside it as given below:

Test it Live

Output

Button Toolbar Using Button Group in Bootstrap 4

The above example shows the toolbar that contains the numbers and arrows to visit next and previous pages on a website.

Sizing Button in a Group

It is easier in Bootstrap 4 to resize buttons by just adding a single class to it. You can add class .btn-group-lg or .btn-group-sm to the <div> element that contains the class .btn-group as given below:

Test it Live

Output

Sizing Button in a Group

The Bootstrap 4 class .btn-group-lg is useful to make the group button large. While you can use the class .btn-group-sm to make the group button small.

Nesting Button Groups with Dropdown Menus

The nesting button group is the way of placing the button group inside another button group. You can also place the dropdown menu inside the button group to mix it with a series of buttons.

To create a nesting button group, you have to place .btn-group inside another .btn-group as given below:

Test it Live

Output

Nesting Button Groups with Dropdown Menus

The above example contains 4 buttons with the last button in the dropdown menu. You can click the last button to check the dropdown menu with links.

Vertical Button Group with Dropdown

The above all button groups are horizontal button groups in Bootstrap 4. However, you can also create a vertical button group using the class .btn-group-vertical in place of the .btn-group as given below:

Test it Live

Output

Vertical Button Group with Dropdown

The above example is the vertical button group that contains 4 buttons. The last button is the dropdown menu that shows the menu on click.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.