iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
These free Bootstrap button examples target Bootstrap 5.3, which the official documentation identifies as version 5.3.8. Copy a snippet, choose a treatment that matches the action, and keep the element’s semantics and accessible label intact. Each example uses Bootstrap classes; include Bootstrap’s stylesheet for the styles to appear.
Set up Bootstrap 5.3 first
Add the mobile viewport meta tag in the document head and load Bootstrap’s CSS. The official getting-started guide provides the current CDN links and advises using the supplied integrity attributes. Check that guide for the exact release URL and integrity value when setting up a project: Bootstrap 5.3 getting started. These examples use the documented button classes in the v5.3 component reference: Bootstrap buttons.
Bootstrap’s base .btn class handles fundamentals such as padding and content alignment. Pair it with a variant for a complete visual treatment.
Recommended Free Tools
Choose a filled or outline button
Use filled buttons when an action should carry stronger visual weight; outline buttons offer a lighter treatment. The variant name conveys the intended role or tone, but it does not replace a clear action label.
#1 Best Overall
Filled primary action
<button type="button" class="btn btn-primary">Save changes</button>
Secondary or status-oriented actions
<button type="button" class="btn btn-secondary">Cancel</button>
<button type="button" class="btn btn-success">Confirm order</button>
<button type="button" class="btn btn-danger">Delete item</button>
<button type="button" class="btn btn-warning">Review warning</button>
<button type="button" class="btn btn-info">More information</button>
<button type="button" class="btn btn-light">Open panel</button>
<button type="button" class="btn btn-dark">View report</button>
<button type="button" class="btn btn-link">Learn more</button>
Bootstrap also documents outline counterparts: use btn-outline-primary, btn-outline-secondary, btn-outline-success, btn-outline-danger, btn-outline-warning, btn-outline-info, btn-outline-light, or btn-outline-dark with btn. For example:
<button type="button" class="btn btn-outline-primary">View details</button>
Check contrast against the actual background, especially for light variants. Do not rely on color alone to communicate meaning; label the action with text or provide an accessible alternative when the design uses an icon.
Rank #2
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
Adjust button size and layout
Use a documented size
<button type="button" class="btn btn-primary btn-lg">Continue</button>
<button type="button" class="btn btn-outline-secondary btn-sm">Dismiss</button>
Bootstrap provides .btn-lg and .btn-sm. For dimensions between or beyond those presets, use CSS variables or custom styles rather than assuming a class that Bootstrap does not document.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Stack full-width actions
For a vertical set of full-width buttons, combine Bootstrap’s grid display and gap utilities:
Rank #3
<div class="d-grid gap-2">
<button type="button" class="btn btn-primary">Create account</button>
<button type="button" class="btn btn-outline-secondary">Sign in instead</button>
</div>
Adjust the layout at breakpoints with responsive display utilities when the buttons should stack on narrow screens but sit differently on wider screens.
Use the right HTML element
Actions belong on buttons
Use a native <button> when activating the control performs an action, such as saving a form or opening a dialog. Set an explicit type: type="button" for ordinary actions, or the appropriate submit type when submitting a form.
Rank #4
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
Navigation belongs on links
Use an anchor with an href when the control navigates to a page or location. Bootstrap’s button classes can style anchors as well as buttons:
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstall<a class="btn btn-primary" href="/account/">Open account</a>
If an anchor triggers in-page functionality rather than navigation, Bootstrap says to add role="button". Prefer a native button for an action when possible; do not leave a navigation link without a meaningful destination.
Best Value
Build a toggle with an announced state
Toggle buttons represent an on/off state, not a one-time action. Bootstrap’s toggle behavior uses its button plugin, so include Bootstrap’s JavaScript as described in the button component documentation. Expose the current state with aria-pressed and update it whenever the state changes:
<button type="button" class="btn btn-primary" data-bs-toggle="button" aria-pressed="false">
Favorite
</button>
Do not use a toggle treatment for a control that simply runs an action once. The state conveyed by the visual appearance and the value of aria-pressed should stay in sync.
Keep focus and custom styling usable
Bootstrap’s base .btn alone does not provide the same explicit hover and focus styling as its button variants. If you use only the base class or heavily customize a variant, preserve a visible keyboard-focus treatment. Test it against the button’s background and surrounding surface, and make sure custom colors retain sufficient contrast.
Bootstrap documents CSS variables and Sass mixins for further customization. Its component reference explains the available options; it does not establish that a particular style is universally more usable or performs better.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

