Button

Button

Buttons trigger actions. Put btn on a <button> or <a>, then add color, style, size and state modifiers.

Class names

Class nameTypeDescription
btnComponentBase button
btn-primaryColorPrimary color
btn-secondaryColorSecondary color
btn-dangerColorDanger color, for destructive actions
btn-outlineStyleTransparent with a border; fills on hover
btn-ghostStyleNo background or border until hover
btn-smSizeSmall
btn-lgSizeLarge
btn-loadingStateShows a spinner; pair with aria-busy="true"

Button

<button class="btn">Default</button>

Colors

<button class="btn btn-primary">Primary</button>
<button class="btn btn-secondary">Secondary</button>
<button class="btn btn-danger">Danger</button>

Outline

<button class="btn btn-outline">Outline</button>

Ghost

<button class="btn btn-ghost">Ghost</button>

Sizes

Medium is the default; there is no btn-md class.

<button class="btn btn-sm">Small</button>
<button class="btn">Medium</button>
<button class="btn btn-lg">Large</button>

Sizes with color

<button class="btn btn-primary btn-sm">Small</button>
<button class="btn btn-primary">Medium</button>
<button class="btn btn-primary btn-lg">Large</button>

Disabled

Use the disabled attribute on <button>, or aria-disabled="true" on a link.

Disabled link
<button class="btn" disabled>Disabled</button>
<a class="btn btn-primary" aria-disabled="true">Disabled link</a>

Loading

The label stays in the DOM, so screen readers still announce it.

<button class="btn btn-loading" aria-busy="true">Saving</button>
<button class="btn btn-primary btn-loading" aria-busy="true">Saving</button>

With an icon

<button class="btn btn-primary">
  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg>
  New file
</button>