Bootstrap 5 Button Group
- Previous Page BS5 Button
- Next Page BS5 Badge
Button Group
Bootstrap 5 allows you to group a series of buttons together in a button group (on a single line):
Please use the class .btn-group
class <div>
element to create a button group:
Example
<div class="btn-group"> <button type="button" class="btn btn-primary">Huawei</button> <button type="button" class="btn btn-primary">DJI</button> <button type="button" class="btn btn-primary">Xiaomi</button> </div>
Tip:Please do not apply button size to each button in the group, but use the class .btn-group-lg
Used for large button groups or to .btn-group-sm
Used for small button groups:
Example
<div class="btn-group btn-group-lg"> <button type="button" class="btn btn-primary">Huawei</button> <button type="button" class="btn btn-primary">DJI</button> <button type="button" class="btn btn-primary">Xiaomi</button> </div>
Vertical Button Groups
Bootstrap 5 also supports vertical button groups:
Please use the class .btn-group-vertical
Create a vertical button group:
Example
<div class="btn-group-vertical"> <button type="button" class="btn btn-primary">Huawei</button> <button type="button" class="btn btn-primary">DJI</button> <button type="button" class="btn btn-primary">Xiaomi</button> </div>
Side-by-Side Button Groups
By default, button groups are 'inline', and multiple button groups will be displayed side by side when there are multiple button groups:
Example
<div class="btn-group"> <button type="button" class="btn btn-primary">Huawei</button> <button type="button" class="btn btn-primary">DJI</button> <button type="button" class="btn btn-primary">Xiaomi</button> </div> <div class="btn-group"> <button type="button" class="btn btn-primary">Geely</button> <button type="button" class="btn btn-primary">Great Wall</button> <button type="button" class="btn btn-primary">Hongqi</button> </div>
Nested Button Groups and Dropdown Menus
Nested button groups can create dropdown menus (you will learn more about dropdown menus in the following chapters):
Example
<div class="btn-group"> <button type="button" class="btn btn-primary">Huawei</button> <button type="button" class="btn btn-primary">DJI</button> <div class="btn-group"> <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">Xiaomi</button> <div class="dropdown-menu"> <a class="dropdown-item" href="#">Phone</a> <a class="dropdown-item" href="#">Tablet</a> </div> </div> </div>
- Previous Page BS5 Button
- Next Page BS5 Badge