bootstrap
  1. bootstrap-buttons

Bootstrap Buttons

Bootstrap provides several styles of buttons that can be customized to fit the needs of your website.

Syntax

To create a Bootstrap button, you can use the following HTML code:

<button type="button" class="btn btn-primary">Primary</button>

In this code, btn is a required class for all buttons, and btn-primary is a class used to define the primary color of the button.

Example

Here is an example of how to create a Bootstrap button

<button type="button" class="btn btn-primary">Click Me!</button>
Try Playground

Variants

Bootstrap includes several button variants, each serving its own semantic purpose, with a few extras thrown in for more control.

<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 Playground

Outline buttons

In Bootstrap, you can create outlined buttons using the btn class along with the btn-outline-* classes.

<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 Playground

Sizes

Fancy larger or smaller buttons? Add .btn-lg or .btn-sm for additional sizes.

<button type="button" class="btn btn-primary btn-lg">Large button</button>
<button type="button" class="btn btn-primary btn-sm">Small button</button>
Try Playground

Explanation

In the code above, we used the following classes to create the button:

  • btn: this is the main class that indicates that this is a button.

Use

Bootstrap buttons can be used for a variety of purposes such as:

  • Submitting forms.
  • Triggering actions such as showing or hiding content.
  • Initiating a download or redirecting users to a new page.

Important Points

  • Bootstrap provides several styles of buttons that can be easily customized.
  • Buttons can be customized using different colors, sizes, and styles.
  • You can use buttons to initiate different actions or navigate to new pages.

Summary

Bootstrap buttons are an essential part of any website's design. By using Bootstrap buttons, you can create a consistent, professional look and feel for your website and provide users with clear calls-to-action.

Published on: