Bootstrap — P4: Buttons

Click-worthy styles in a single class

Buttons are made easy with Bootstrap. The team at Bootstrap has taken the guesswork out of button design and has created a set of styles that look modern. Only rarely do I sway away from the default bootstrap design. Buttons were briefly looked at in our previous article. We’ll go into further detail in this section.

https://www.dinocajic.com/bootstrap-p3-margin-and-padding/

The btn class must be applied to each button in order to start using bootstrap’s button styles. Let’s see the changes between the default button style and bootstrap’s version.

<button>Unstyled</button>
<button class="btn">Styled with Bootstrap</button>

When the btn class is applied to the button, the styled button appears as just text on the screen. The styled button also has more padding than the default style.

The size of the button can be changed by applying the btn-lg and btn-sm styles. Note that the btn class must remain in place. The additional classes inherit behavior from the btn class.

As was discussed in the previous article, certain button colors are predefined in bootstrap for specific scenarios. Let’s look at them again.

<button type="button" class="btn btn-primary">btn-primary</button>
<button type="button" class="btn btn-secondary”>
    btn-secondary
</button>
<button type="button" class="btn btn-success">btn-success</button>
<button type="button" class="btn btn-danger">btn-danger</button>
<button type="button" class="btn btn-warning">btn-warning</button>
<button type="button" class="btn btn-info">btn-info</button>
<button type="button" class="btn btn-light">btn-light</button>
<button type="button" class="btn btn-dark">btn-dark</button>
<button type="button" class="btn btn-link">btn-link</button>

The size of the button can be changed by applying the btn-lg and btn-sm styles. Note that the btn class must remain in place. The additional classes inherit behavior from the btn class.

<div>
    <button type="button" class="btn btn-primary btn-sm”>
        Small
    </button>
    <button type="button" class="btn btn-primary”>
        Standard
    </button>
    <button type="button" class="btn btn-primary btn-lg”>
        Large
    </button>
</div>

Buttons can also be outlined with the outline classes. The buttons will be transparent with only the border and the text outlined in the specific color.

<div>
    <button type="button" class="btn btn-outline-danger”>
        Danger Outlined
    </button>
    <button type="button" class="btn btn-outline-primary”>
        Primary Outlined
    </button>
</div>
<div class="mt-4 p-4 bg-black">
    <button type="button" class="btn btn-outline-danger”>
        Danger Outlined
    </button>
    <button type="button" class="btn btn-outline-primary”>
        Primary Outlined
    </button>
</div>

 BOOTSTRAP Series

Continue your Bootstrap Learning.

Bootstrap — P3: Margin and Padding

Space elements the smart way

Bootstrap — P3: Margin and Padding

Part three of our Bootstrap essentials series drills into spacing utilities—margin (m*) and padding (p*) helpers, responsive breakpoints, and directional shorthands. Learn to compose clean layouts fast without custom CSS.

Bootstrap — P4: Buttons

Click-worthy styles in a single class

Bootstrap — P4: Buttons

Part four of our Bootstrap essentials series dives into buttons—primary, outline, and link variants, size modifiers, block display, and button groups. Learn how to mix utility classes, toggle states, and tailor colors in Sass for on-brand, accessible CTAs.

Bootstrap — P5: Responsive Images

Make every pic fit perfectly.

Bootstrap — P5: Responsive Images

Part five of our Bootstrap essentials series shows how to keep images sharp and adaptable with .img-fluid, responsive picture sources, alignment classes, and lazy-loading tips—ensuring perfect fit on every device.

Leave a Reply