Buttons

Use Bootstrap's custom button styles for actions in forms, dialogs, and more with support for multiple sizes, states, and more.

On this page

Examples

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

Last clicked button
vue
<template>
  <b-button
    button="primary"
    @click="clicked"
  >
    Primary
  </b-button>
  <b-button
    button="secondary"
    @click="clicked"
  >
    Secondary
  </b-button>
  <b-button
    button="success"
    @click="clicked"
  >
    Success
  </b-button>
  <b-button
    button="danger"
    @click="clicked"
  >
    Danger
  </b-button>
  <b-button
    button="warning"
    @click="clicked"
  >
    Warning
  </b-button>
  <b-button
    button="info"
    @click="clicked"
  >
    Info
  </b-button>
  <b-button
    button="light"
    @click="clicked"
  >
    Light
  </b-button>
  <b-button
    button="dark"
    @click="clicked"
  >
    Dark
  </b-button>
  <b-button
    button="link"
    @click="clicked"
  >
    Link
  </b-button>
  <b-dl margin="t-5">
    <b-dt col="sm-3">
      Last clicked button
    </b-dt>
    <b-dd col="sm-9">
      {{ lastClicked }}
    </b-dd>
  </b-dl>
</template>
<script setup>
 const lastClicked = ref('')
 const clicked = (event) => {
  lastClicked.value = event.srcElement.className
 }
</script>

Disable text wrapping

If you don't want the button text to wrap, you can add the text-wrap="nowrap" attribute to the button. In Sass, you can set $btn-white-space: nowrap to disable text wrapping for each button.

Button tags

You can also use `button` attribute on <b-a> or <b-input> elements (though some browsers may apply a slightly different rendering).

When using button classes on <b-a> elements that are used to trigger in-page functionality (like collapsing content), rather than linking to new pages or sections within the current page, these links should be given a type attribute to appropriately convey their purpose to assistive technologies such as screen readers.

Link
vue
<template>
  <b-a
    button="primary"
    href="#"
  >
    Link
  </b-a>
  <b-button
    button="primary"
    type="submit"
  >
    Button
  </b-button>
</template>

Outline buttons

In need of a button, but not the hefty background colors they bring? Replace the default modifier classes with the button="outline-*" ones to remove all background images and colors on any button.

vue
<template>
  <b-button button="outline-primary">
    Primary
  </b-button>
  <b-button button="outline-secondary">
    Secondary
  </b-button>
  <b-button button="outline-success">
    Success
  </b-button>
  <b-button button="outline-danger">
    Danger
  </b-button>
  <b-button button="outline-warning">
    Warning
  </b-button>
  <b-button button="outline-info">
    Info
  </b-button>
  <b-button button="outline-light">
    Light
  </b-button>
  <b-button button="outline-dark">
    Dark
  </b-button>
</template>

Sizes

Fancy larger or smaller buttons? Add size="lg" or size="sm" mfor additional sizes.

vue
<template>
  <b-button
    button="primary"
    size="lg"
  >
    Large button
  </b-button>
  <b-button
    button="secondary"
    size="lg"
  >
    Large button
  </b-button>
</template>
vue
<template>
  <b-button
    button="primary"
    size="sm"
  >
    Small button
  </b-button>
  <b-button
    button="secondary"
    size="sm"
  >
    Small button
  </b-button>
</template>

Disabled state

Make buttons look inactive by adding the disabled boolean attribute. Disabled buttons have pointer-events: none applied to, preventing hover and active states from triggering.

vue
<template>
  <b-button
    disabled
    button="primary"
    size="lg"
  >
    Primary button
  </b-button>
  <b-button
    disabled
    button="secondary"
    size="lg"
  >
    Secondary button
  </b-button>
</template>

Link functionality caveat

To cover cases where, you have to keep the href attribute on a disabled link, the .disabled class uses pointer-events: none to try to disable the link functionality of <a>s. Note that this CSS property is not yet standardized for HTML, but all modern browsers support it.

In addition, even in browsers that do support pointer-events: none, keyboard navigation remains unaffected, meaning that sighted keyboard users and users of assistive technologies will still be able to activate these links.

So to be safe, in addition to aria-disabled="true", also include a tabindex="-1" attribute on these links to prevent them from receiving keyboard focus, and use custom JavaScript to disable their functionality altogether.

vue
<template>
  <b-a
    disabled
    href="#"
    button="primary"
    size="lg"
    tabindex="-1"
  >
    Primary link
  </b-a>
  <b-a
    disabled
    href="#"
    button="secondary"
    size="lg"
    tabindex="-1"
  >
    Link
  </b-a>
</template>

Block buttons

Create responsive stacks of full-width, "block buttons" like those in Bootstrap 4 with a mix of our display and gap utilities.

By using utilities instead of button specific classes, we have much greater control over spacing, alignment, and responsive behaviors.

vue
<template>
  <b-div
    display="grid"
    gap="2"
  >
    <b-button button="primary">
      Button
    </b-button>
    <b-button button="primary">
      Button
    </b-button>
  </b-div>
</template>

Here we create a responsive variation, starting with vertically stacked buttons until the md breakpoint, where display="md-block" replaces the display="grid" class, thus nullifying the gap="2" attribute.

Resize your browser to see them change.

vue
<template>
  <b-div
    display="grid md-block"
    gap="2"
  >
    <b-button button="primary">
      Button
    </b-button>
    <b-button button="primary">
      Button
    </b-button>
  </b-div>
</template>

You can adjust the width of your block buttons with grid column width classes. For example, for a half-width "block button", use col="6".

Center it horizontally with margin="x-auto", too.

vue
<template>
  <Col
    display="grid"
    gap="2"
    margin="x-auto"
    col="6"
  >
    <b-button button="primary">
      Button
    </b-button>
    <b-button button="primary">
      Button
    </b-button>
  </Col>
</template>

Additional attributes can be used to adjust the alignment of buttons when horizontal.

Here we've taken our previous responsive example and added some flex attributes and a margin utility on the button to right align the buttons when they're no longer stacked.

vue
<template>
  <b-div
    display="grid md-flex"
    gap="2"
    justify-content="md-end"
  >
    <b-button
      button="primary"
      margin="e-md-2"
    >
      Button
    </b-button>
    <b-button button="primary">
      Button
    </b-button>
  </b-div>
</template>

Button plugin

Button plug-ins allow you to create simple on/off toggle buttons.

tip

Visually, these toggle buttons are identical to the checkbox toggle button . However, they are conveyed differently by assistive technologies: the checkbox toggles will be announced by screen readers as "checked"/"not checked" (since, despite their appearance, they are fundamentally still checkboxes), whereas these toggle buttons will be announced as "button"/"button pressed". The choice between these two approaches will depend on the type of toggle you are creating, and whether or not the toggle will make sense to users when announced as a checkbox or as an actual button.

Toggle states

Add toggle="button" to toggle a button's active state.

If you're pre-toggling a button, you must manually add the active attribute to ensure that it is conveyed appropriately to assistive technologies.

vue
<template>
  <b-button
    button="primary"
    toggle="button"
  >
    Toggle button
  </b-button>
  <b-button
    button="primary"
    toggle="button"
    active
  >
    Active Toggle button
  </b-button>
  <b-button
    button="primary"
    toggle="button"
    disabled
  >
    Disabled Toggle button
  </b-button>
</template>
vue
<template>
  <b-a
    button="primary"
    toggle="button"
  >
    Toggle link
  </b-a>
  <b-a
    button="primary"
    toggle="button"
    active
  >
    Active toggle link
  </b-a>
  <b-a
    button="primary"
    toggle="button"
    disabled
  >
    Disabled toggle link
  </b-a>
</template>