Nearby lessons
11 of 39🔘 BS5 Buttons
📌 What Are Bootstrap 5 Buttons?
Bootstrap 5 buttons are styled elements used to trigger actions like submitting forms, opening modals, or navigating.
You create them by adding the btn class plus a btn-* variant class (for example btn-primary).
🎨 Button Styles & Color Variants (btn, btn-*)
Start with the base btn class, then add a color class to show the meaning of the action.
Common button variants:
btn– basic gray buttonbtn-primary– important primary actionbtn-secondary– secondary actionbtn-success– success / positivebtn-info– informationbtn-warning– warningbtn-danger– danger / deletebtn-dark– dark theme buttonbtn-light– light theme buttonbtn-link– button that looks like a link
⬛ Outline Buttons (.btn-outline-*)
Outline buttons use a colored border with a transparent background.
They are useful when you want a lighter visual style.
📏 Button Sizes (.btn-sm, .btn-lg)
Change the size of buttons with:
.btn-sm– small button.btn-lg– large button
🔄 Active & Disabled Buttons (including links)
Buttons can show different states:
.active– pressed / toggled ondisabledattribute – disables<button>and<input>.disabledclass – visually disables a link button (<a>)
🔁 Spinner Buttons (Loading State)
You can add spinners inside buttons to show loading:
.spinner-border– border spinner.spinner-grow– growing spinner
📚 Block & Full-Width Buttons (d-grid, gap-*)
Use the .d-grid helper class on the parent to make block level, full-width buttons.
Add .gap-* to control the space between multiple buttons.
👆 Button Tags (a, button, input)
You can apply button styles to different HTML elements:
<button>– best for actions<a>– navigation links styled as buttons<input type="submit">– form submit buttons
✅ Button Best Practices
- Use semantic HTML: Prefer
<button>for actions,<a>for links. - Make labels clear: Button text should describe the action (e.g. “Save”, “Delete”).
- Show feedback: Use disabled and loading states while actions are in progress.
- Use colors with meaning: Primary for main actions, danger for destructive actions.