Advertisement

Google Ad Slot: content-top

Bootstrap 5 Buttons


Bootstrap 5 provides a variety of button styles and classes to create interactive buttons with different looks and behaviors.

Example
<button type="button" class="btn btn-primary">Primary</button>
Try it yourself

Button Variants:

Bootstrap offers several predefined styles:

Example
<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</button>
Try it yourself

Button Sizes:

Bootstrap provides classes for different sizes:

Example
<button type="button" class="btn btn-primary btn-lg">Large Button</button>
<button type="button" class="btn btn-secondary btn-sm">Small Button</button>
<button type="button" class="btn btn-danger btn-block">Block Button</button>
Try it yourself

Outline Buttons:

Use outline styles for buttons:

Example
<button type="button" class="btn btn-outline-primary">Primary</button>
<button type="button" class="btn btn-outline-secondary">Secondary</button>
<button type="button" class="btn btn-outline-success">Success</button>
<button type="button" class="btn btn-outline-danger">Danger</button>
<button type="button" class="btn btn-outline-warning">Warning</button>
<button type="button" class="btn btn-outline-info">Info</button>
<button type="button" class="btn btn-outline-light">Light</button>
<button type="button" class="btn btn-outline-dark">Dark</button>
Try it yourself

Disabled Buttons:

Disable a button using the disabled attribute or the .disabled class:

Example
<button type="button" class="btn btn-primary" disabled>Disabled Button</button>
<button type="button" class="btn btn-secondary disabled">Disabled Button</button>
Try it yourself

Loading Buttons:

Add a spinner for loading states:

Example
<button class="btn btn-primary" type="button" disabled>
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"> </span>
Loading...
</button>
<button class="btn btn-primary" disabled>
<span class="spinner-grow spinner-grow-sm"></span>
Loading..
</button>
Try it yourself