Buttons are the primary interactive call-to-action elements on any website. Bootstrap 5 provides a powerful set of button styles, outlines, size modifiers, active/disabled states, and button group containers that deliver tactile feedback across desktop clicks and mobile taps.
To style a button, always apply the base .btn class followed by a semantic contextual modifier class (e.g. .btn-primary):
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-secondary">Secondary</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-danger">Danger</button>
<button type="button" class="btn btn-warning">Warning</button>
<button type="button" class="btn btn-info">Info</button>
<button type="button" class="btn btn-light">Light</button>
<button type="button" class="btn btn-dark">Dark</button>
<button type="button" class="btn btn-link">Link Style</button>
.btn-outline-*)Outline buttons feature a transparent background with a colored border and text. On hover, the button smoothly fills with solid background color:
<button type="button" class="btn btn-outline-primary">Outline Primary</button>
<button type="button" class="btn btn-outline-success">Outline Success</button>
<button type="button" class="btn btn-outline-danger">Outline Danger</button>
Modify button sizes using .btn-lg (large) or .btn-sm (small). In Bootstrap 5, the legacy .btn-block class was removed; full-width buttons are now created using modern responsive grid or .d-grid flexbox utilities:
<!-- Sizing Modifiers -->
<button type="button" class="btn btn-primary btn-lg">Large Action Button</button>
<button type="button" class="btn btn-primary btn-sm">Small Action Button</button>
<!-- Modern Full-Width Button using d-grid (Mobile-First) -->
<div class="d-grid gap-2 col-6 mx-auto mt-3">
<button class="btn btn-success btn-lg" type="button">Full Width Checkout →</button>
</div>
.btn-group)Combine a series of buttons together on a single line with the .btn-group container. Border radiuses between adjoining buttons are automatically merged for a sleek toolbar aesthetic:
<div class="btn-group" role="group" aria-label="Editor Alignment">
<button type="button" class="btn btn-outline-secondary"><i class="fa fa-align-left"></i> Left</button>
<button type="button" class="btn btn-outline-secondary active"><i class="fa fa-align-center"></i> Center</button>
<button type="button" class="btn btn-outline-secondary"><i class="fa fa-align-right"></i> Right</button>
</div>
When styling an anchor tag as a button (<a class="btn btn-primary" href="..." role="button">), you must add role="button" to inform screen readers that this element behaves as a button rather than a navigational hyperlink.
Strengthen your responsive web design mastery by studying these connected classes:
Explore solid, outline, and disabled button color states.
Combine action buttons with toggleable dropdown menus.
Add spinner-border loading feedback indicators to submit buttons.
Handle form submission validation states and disable on submit.
.btn-block. In Bootstrap 5, wrap your button inside <div class='d-grid'>. You can also specify responsive widths like d-grid col-md-6 mx-auto.
.btn-group-vertical instead of .btn-group. Buttons will stack vertically with joined borders.
<button> tags, add the native HTML attribute disabled. For <a> tags, add the class .disabled and the attribute aria-disabled='true'.
Advance your practical frontend engineering skills with the next topic in our synchronized curriculum.
Continue to Class 13: Form Controls & Checks → Previous: ← Class 11: Images & Figures | Full Syllabus