Class 12 of 48 • Content & Typography

Bootstrap 5 Buttons, Outlines, Sizes & Button Groups

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.

Bootstrap 5 Buttons, Outlines, Sizes, and Button Groups
Figure 12: Button anatomy highlighting solid fills, outline variants, size modifiers (.btn-lg, .btn-sm), and grouped toolbars.

1. The Solid Theme Buttons

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>

2. Outline Buttons (.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>

3. Button Sizing & Block Level Buttons

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 &rarr;</button>
</div>

4. Button Groups (.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>

Accessibility Note for Links as Buttons

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.

Explore Related Bootstrap Tutorials & Next Steps

Strengthen your responsive web design mastery by studying these connected classes:

Theme Colors & Contrast

Explore solid, outline, and disabled button color states.

Dropdown Split Buttons

Combine action buttons with toggleable dropdown menus.

Loading Spinners inside Buttons

Add spinner-border loading feedback indicators to submit buttons.

Form Submit Buttons & States

Handle form submission validation states and disable on submit.

Frequently Asked Questions (FAQ) - Student & Interview Review

In Bootstrap 4, full-width buttons used .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.
Use .btn-group-vertical instead of .btn-group. Buttons will stack vertically with joined borders.
For <button> tags, add the native HTML attribute disabled. For <a> tags, add the class .disabled and the attribute aria-disabled='true'.

Next Step in Your Bootstrap Learning Path:

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

Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Reddit

You may also like this!