Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Bootstrap5 Button Groups

Bootstrap5 Button Groups

Bootstrap 5 allows us to place buttons on the same line.

can be done during

Add the .btn-group class to the element to create a button group.

Example

<div class="btn-group">
<button type="button" class=">

btn btn-primary

"

Apple

button

<button type="button" class=">

btn btn-primary

"

Samsung

button

<button type="button" class=">

btn btn-primary

"

Sony

button

div

Try it »

Tip: We can use the .btn-group-lg|sm classes to set the size of a button group.

Example

<div class=">

btn-group btn-group-lg

"

<button type="button" class=">

btn btn-primary

"

Apple

button

<button type="button" class=">

btn btn-primary

"

Samsung

button

<button type="button" class=">

btn btn-primary

"

Sony

button

div

Try it »


Vertical button groups

Use the .btn-group-vertical class to create a vertical button group:

Example

<div class="btn-group-vertical">
<button type="button" class=">

btn btn-primary

"

Apple

button

<button type="button" class=">

btn btn-primary

"

Samsung

button

<button type="button" class=">

btn btn-primary

"

Sony

button

div

Try it »


Nested Button Groups and Dropdowns

We can set up a dropdown inside a button group:

Example

<div class="btn-group">
<button type="button" class=">

btn btn-primary

"

Apple

button

<button type="button" class=">

btn btn-primary

"

Samsung

button

<div class="btn-group">
<button type="button" class=">

btn btn-primary dropdown-toggle

"

data-bs-toggle

=

"

dropdown

"

Sony

button

<div class="dropdown-menu">
<a class="dropdown-item" href="" Tablet a>
<a class="dropdown-item" href="" Smartphone a div div div>

Try it »


Vertical Button Groups and Dropdowns

Example

<div class="btn-group-vertical">
<button type="button" class=">

btn btn-primary

"

Apple

button

<button type="button" class=">

btn btn-primary

"

Samsung

button

<div class="btn-group">
<button type="button" class=">

btn btn-primary dropdown-toggle

"

data-bs-toggle

=

"

dropdown

"

Sony

button

<ul class="dropdown-menu">
<li>
<a class="dropdown-item" href="" Tablet a li>
<li>
<a class="dropdown-item" href="" Smartphone a li ul div div>

Try it »


Multiple Button Groups

Button groups can be displayed side by side on the same line:

Example

<div class="btn-group">
<button type="button" class=">

btn btn-primary

"

Apple

button

<button type="button" class=">

btn btn-primary

"

Samsung

button

<button type="button" class=">

btn btn-primary

"

Sony

button

div

<div class="btn-group">
<button type="button" class=">

btn btn-primary

"

BMW

button

<button type="button" class=">

btn btn-primary

"

Mercedes

button

<button type="button" class=">

btn btn-primary

"

Volvo

button

div

Try it »