Robert's Resume

Buttons

Code

.btn

.btn-*

.btn-outline-*

.btn-sm|lg

.d-grid

.g-*

.active

disabled|.disabled

.spinner-border|-sm

Top

Definitions

Button
▪ Applies default styling including rounded corners.
Colored Buttons
▪ Use contextual classes to style buttons.
Outline
▪ Adds colored border and text to a white button.
Sizes
▪ Choose between small and large.
Block Level Buttons
▪ Use grids to create wider buttons.
Active
▪ Adds a slightly darker color.
Disabled
▪ Adds opacity.
Spinner
▪ Add a spinner to the button.
Top

Key Points

  • You can apply button styling to links and inputs, just be careful to use the correct accessibility features.
  • .btn-block is deprecated in Bootstrap 5.
  • Spinners will be covered in more depth here.
  • Top

Colors

Add .btn to a <button> element. For colors, also add btn-*, where * indicates a contextual class.

Top

Button Outline

Add .btn-outline-* to a <button> element, where * indicates a contextual class.

NOTE: Not all outlines show up well and are only meant for dark themes (e.g. Light), while others don't work at all (e.g. Basic and Link).

Top

Small Buttons

Add .btn-sm to a <button> element.

Top

Large Buttons

Add .btn-lg to a <button> element.

Top

Block Level Buttons

Wrap your button inside a <div> element with .d-grid and use .gap to control the space between them.

NOTE: You can achieve the same result by simply changing the width of the button to 100% (.w-100).

Top

Modified Block Level Buttons

To change the size of Block Level Buttons, add .col-* to either the container or the individual button.

To center Block Level Buttons, add .mx-auto in addition to .col-*.

Top

Responsive Buttons

To make buttons stack responsively, add .d-*-flex to the grid container, where * indicates a breakpoint.

To align the buttons when horizontal, add justify-content-*-+ to the grid container, where the * indicates a breakpoint and the + indicates start, center, end, between or around.

Top

Active/Disabled Buttons

Add .active to a button to make it appear pressed.

Add .disabled, or use the disabled attribute to a button to make it unclickable.

Top

Spinner Buttons

Add a <span> before your button text with .spinner-border|grow and an optional .spinner-border|grow-sm to make it small.

Top