Button

How it works

Use Bootstrap's custom button styles for actions in forms, dialogs, and more with support for multiple sizes, states, and more. There is three types of tags that can be used for create a button: button, a and input.

Basic example

Link Link Disabled Link
<x-button>Default</x-button>
<x-button type="submit">Submit</x-button>
<x-button disabled>Disabled</x-button>
<x-button.link>Link</x-button.link>
<x-button.link href="/docs/components/buttons">Link</x-button.link>
<x-button.link disabled>Disabled Link</x-button.link>
<x-button.input>Type input</x-button.input>
<button type="button"
      class="btn btn-primary">Default</button> <button type="submit"
      class="btn btn-primary">Submit</button> <button type="button"
      class="btn btn-primary"
      disabled="disabled">Disabled</button> <a href="#"
      role="button"
      class="btn btn-primary">Link</a> <a href="/docs/components/buttons"
      class="btn btn-primary">Link</a> <a href="#"
      role="button"
      tabindex="-1"
      aria-disabled="true"
      class="btn btn-primary disabled">Disabled Link</a>
<form>
  <input type="button"
        class="btn btn-primary"
        value="Type input">
</form>

Colored example

Bootstrap includes several predefined button styles, each serving its own semantic purpose, with a few extras thrown in for more control. In need of a button, but not the hefty background colors they bring? Add prop outline to remove all background colors on any button.


<x-button color="primary">primary</x-button>
<x-button color="secondary">secondary</x-button>
<x-button color="success">success</x-button>
<x-button color="danger">danger</x-button>
<x-button color="warning">warning</x-button>
<x-button color="info">info</x-button>
<x-button color="light">light</x-button>
<x-button color="dark">dark</x-button>
<x-button color="link">link</x-button>

<x-button color="primary" outline>primary</x-button>
<x-button color="secondary" outline>secondary</x-button>
<x-button color="success" outline>success</x-button>
<x-button color="danger" outline>danger</x-button>
<x-button color="warning" outline>warning</x-button>
<x-button color="info" outline>info</x-button>
<x-button color="light" outline>light</x-button>
<x-button color="dark" outline>dark</x-button>
<x-button color="link" outline>link</x-button>
<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>

<hr>
<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> <button type="button"
      class="btn btn-outline-link">Link</button>

Sizes

All sizes variant. Use prop small or large to change default button size.

<x-button small>Small</x-button>
<x-button>Normal</x-button>
<x-button large>Large</x-button>
<button type="button"
      class="btn btn-primary btn-sm">Small</button> <button type="button"
      class="btn btn-primary">Normal</button> <button type="button"
      class="btn btn-primary btn-lg">Large</button>

Toggle states

Button with toggle states. Add prop active to make active by default.

<x-button toggle="button">Toggle Button</x-button>
<x-button toggle="button" active>Active</x-button>
<x-button toggle="button">Toggle Link</x-button>
<x-button toggle="button" active>Active Link</x-button>
<button type="button"
      data-bs-toggle="button"
      aria-pressed="false"
      class="btn btn-primary">Toggle Button</button> <button type="button"
      data-bs-toggle="button"
      aria-pressed="true"
      class="btn btn-primary active">Active</button> <button type="button"
      data-bs-toggle="button"
      aria-pressed="false"
      class="btn btn-primary">Toggle Link</button> <button type="button"
      data-bs-toggle="button"
      aria-pressed="true"
      class="btn btn-primary active">Active Link</button>

Button group

Group a series of buttons together on a single line or stack them in a vertical column by wrapping buttons inside component x-button.group as shown below. Ensure correct label for assistive technologies such as screen readers by using prop label. You can also use prop size to x-button.group component instead of applying button sizing to every button in a group.

<x-button.group label="My button group">
    <x-button.link active current>Left</x-button.link>
    <x-button.link>Middle</x-button.link>
    <x-button.link>Right</x-button.link>
</x-button.group>

<x-button.group label="My large button group" size="lg">
    <x-button.link active current>Left</x-button.link>
    <x-button.link>Middle</x-button.link>
    <x-button.link>Right</x-button.link>
</x-button.group>
<div role="group"
     aria-label="My button group"
     class="btn-group">
  <a href="#"
       role="button"
       aria-current="1"
       class="btn btn-primary active">Left</a> <a href="#"
       role="button"
       class="btn btn-primary">Middle</a> <a href="#"
       role="button"
       class="btn btn-primary">Right</a>
</div>

<hr>

<div role="group"
     aria-label="My large button group"
     class="btn-group">
  <a href="#"
       role="button"
       aria-current="1"
       class="btn btn-primary active">Left</a> <a href="#"
       role="button"
       class="btn btn-primary">Middle</a> <a href="#"
       role="button"
       class="btn btn-primary">Right</a>
</div>

Button toolbar

Combine sets of button groups into button toolbars for more complex components. Use utility classes as needed to space out groups, buttons, and more. Ensure correct label for assistive technologies such as screen readers by using prop label.

<x-button.toolbar label="My button toolbar">
    <x-button.group label="My first button group" class="me-2">
        <x-button.link active current>1</x-button.link>
        <x-button.link>2</x-button.link>
        <x-button.link>3</x-button.link>
    </x-button.group>

    <x-button.group label="My second button group">
        <x-button.link>4</x-button.link>
        <x-button.link>5</x-button.link>
        <x-button.link>6</x-button.link>
    </x-button.group>
</x-button.toolbar>
<div role="toolbar"
     aria-label="My button toolbar"
     class="btn-toolbar">
  <div role="group"
       aria-label="My first button group"
       class="btn-group me-2">
    <a href="#"
         role="button"
         aria-current="1"
         class="btn btn-primary active">1</a> <a href="#"
         role="button"
         class="btn btn-primary">2</a> <a href="#"
         role="button"
         class="btn btn-primary">3</a>
  </div>

  <div role="group"
       aria-label="My second button group"
       class="btn-group">
    <a href="#"
         role="button"
         class="btn btn-primary">4</a> <a href="#"
         role="button"
         class="btn btn-primary">5</a> <a href="#"
         role="button"
         class="btn btn-primary">6</a>
  </div>
</div>