Loading...
Skip to main content

Button

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

Button renders a native button, or an anchor when given href. Its variant, theme, size, icon, styled, active, and disabled props generate the styles described below. Use ButtonInput for input elements and ToggleButton for checkbox- or radio-backed controls.

Base class

Button applies its base button styles automatically. Set its variant and theme props to choose the visual style and color.

<div className="d-flex flex-wrap gap-2 align-items-center overflow-auto">
<Button>
Base class
</Button>
</div>

Use Button's className prop to add custom styles; built-in variants can be combined with the theme prop or extended in your own styles.

Playground

Bootstrap includes several button variants, each serving its own semantic purpose, with a few extras thrown in for more control. Combined with our utilities, you have a very powerful set of defaults to choose from.

Style
Rounded
<div className="d-flex flex-wrap align-items-center gap-2">
<Button
styled
theme="primary"
variant="solid"
>
Button
</Button>
<Button
styled
theme="primary"
variant="solid"
>
<Icon
aria-hidden="true"
name="arrow-left"
/>
Left icon
</Button>
<Button
styled
theme="primary"
variant="solid"
>
Right icon
<Icon
aria-hidden="true"
name="arrow-right"
/>
</Button>
<Button
aria-label="Icon only"
icon
styled
theme="primary"
variant="solid"
>
<Icon
aria-hidden="true"
name="plus-lg"
/>
</Button>
</div>

Variants

Compare all button variants and styles at once:

<div className="md:justify-items-start d-grid grid-cols-4 gap-2 overflow-auto">
<Button
theme="primary"
variant="solid"
>
Primary
</Button>
<Button
theme="primary"
variant="outline"
>
Primary
</Button>
<Button
theme="primary"
variant="subtle"
>
Primary
</Button>
<Button
theme="primary"
variant="text"
>
Primary
</Button>
<Button
theme="accent"
variant="solid"
>
Accent
</Button>
<Button
theme="accent"
variant="outline"
>
Accent
</Button>
<Button
theme="accent"
variant="subtle"
>
Accent
</Button>
<Button
theme="accent"
variant="text"
>
Accent
</Button>
<Button
theme="secondary"
variant="solid"
>
Secondary
</Button>
<Button
theme="secondary"
variant="outline"
>
Secondary
</Button>
<Button
theme="secondary"
variant="subtle"
>
Secondary
</Button>
<Button
theme="secondary"
variant="text"
>
Secondary
</Button>
<Button
theme="success"
variant="solid"
>
Success
</Button>
<Button
theme="success"
variant="outline"
>
Success
</Button>
<Button
theme="success"
variant="subtle"
>
Success
</Button>
<Button
theme="success"
variant="text"
>
Success
</Button>
<Button
theme="danger"
variant="solid"
>
Danger
</Button>
<Button
theme="danger"
variant="outline"
>
Danger
</Button>
<Button
theme="danger"
variant="subtle"
>
Danger
</Button>
<Button
theme="danger"
variant="text"
>
Danger
</Button>
<Button
theme="warning"
variant="solid"
>
Warning
</Button>
<Button
theme="warning"
variant="outline"
>
Warning
</Button>
<Button
theme="warning"
variant="subtle"
>
Warning
</Button>
<Button
theme="warning"
variant="text"
>
Warning
</Button>
<Button
theme="info"
variant="solid"
>
Info
</Button>
<Button
theme="info"
variant="outline"
>
Info
</Button>
<Button
theme="info"
variant="subtle"
>
Info
</Button>
<Button
theme="info"
variant="text"
>
Info
</Button>
<Button
theme="inverse"
variant="solid"
>
Inverse
</Button>
<Button
theme="inverse"
variant="outline"
>
Inverse
</Button>
<Button
theme="inverse"
variant="subtle"
>
Inverse
</Button>
<Button
theme="inverse"
variant="text"
>
Inverse
</Button>
</div>

Conveying meaning to assistive technologies: Color provides only a visual indication. Ensure the meaning is also clear from the content or included in accessible text.

Link buttons

Set variant="link" on Button to make it look like a link.

<div className="d-flex flex-wrap gap-2 align-items-center overflow-auto">
<Button variant="link">
Link
</Button>
</div>

Link buttons can also be styled with the theme colors.

<div className="d-flex flex-wrap gap-2 align-items-center overflow-auto">
<Button
theme="primary"
variant="link"
>
Primary
</Button>
<Button
theme="accent"
variant="link"
>
Accent
</Button>
<Button
theme="secondary"
variant="link"
>
Secondary
</Button>
<Button
theme="success"
variant="link"
>
Success
</Button>
<Button
theme="danger"
variant="link"
>
Danger
</Button>
<Button
theme="warning"
variant="link"
>
Warning
</Button>
<Button
theme="info"
variant="link"
>
Info
</Button>
<Button
theme="inverse"
variant="link"
>
Inverse
</Button>
</div>

Styled buttons

Set the styled prop on a solid Button to add gradients and shadows for visual depth. Customize the effect further with CSS variables.

<div className="d-flex flex-wrap gap-2 overflow-auto">
<Button
styled
theme="primary"
variant="solid"
>
Primary
</Button>
<Button
styled
theme="accent"
variant="solid"
>
Accent
</Button>
<Button
styled
theme="secondary"
variant="solid"
>
Secondary
</Button>
<Button
styled
theme="success"
variant="solid"
>
Success
</Button>
<Button
styled
theme="danger"
variant="solid"
>
Danger
</Button>
<Button
styled
theme="warning"
variant="solid"
>
Warning
</Button>
<Button
styled
theme="info"
variant="solid"
>
Info
</Button>
<Button
styled
theme="inverse"
variant="solid"
>
Inverse
</Button>
</div>

The gradient and shadow can be customized via CSS variables:

VariableDescription
--bs-btn-gradient-startTop of gradient (default: rgb(255 255 255 / 12.5%))
--bs-btn-gradient-endBottom of gradient (default: rgb(0 0 0 / 7.5%))
--bs-btn-border-mix-colorColor to mix with the button background (default: #000)
--bs-btn-border-mix-amountAmount of color to mix with the button background (default: 10%)
--bs-btn-border-hover-mix-amountAmount of color to mix with the button background on hover (default: 12.5%)
--bs-btn-border-active-mix-amountAmount of color to mix with the button background on active (default: 20%)
--bs-btn-shadowResting state shadow
--bs-btn-active-shadowPressed/active state shadow

Button tags

Button renders a native <button> by default and renders an <a> when href is provided. In either case, its default ARIA role is button; provide an explicit role only when you need to override it.

ButtonInput renders an <input> element with native button behavior.

Link
<div className="d-flex flex-wrap gap-2 overflow-auto">
<Button
href="#"
theme="primary"
variant="solid"
>
Link
</Button>
<Button
theme="primary"
type="submit"
variant="solid"
>
Button
</Button>
<ButtonInput
defaultValue="Input"
theme="primary"
type="button"
variant="solid"
/>
<ButtonInput
defaultValue="Submit"
theme="primary"
type="submit"
variant="solid"
/>
<ButtonInput
defaultValue="Reset"
theme="primary"
type="reset"
variant="solid"
/>
</div>

Sizes

Set size="lg" or size="sm" on Button for a larger or smaller size.

<div className="d-flex flex-wrap gap-2 align-items-center overflow-auto">
<Button
size="lg"
theme="primary"
variant="solid"
>
Large button
</Button>
<Button
size="lg"
theme="secondary"
variant="solid"
>
Large button
</Button>
</div>
<div className="d-flex flex-wrap gap-2 align-items-center overflow-auto">
<Button
size="sm"
theme="primary"
variant="solid"
>
Small button
</Button>
<Button
size="sm"
theme="secondary"
variant="solid"
>
Small button
</Button>
</div>
<div className="d-flex flex-wrap gap-2 align-items-center overflow-auto">
<Button
size="xs"
theme="primary"
variant="solid"
>
Extra small button
</Button>
<Button
size="xs"
theme="secondary"
variant="solid"
>
Extra small button
</Button>
</div>

You can even roll your own custom sizing with CSS variables:

<div className="d-flex flex-wrap gap-2 align-items-center overflow-auto">
<Button
style={{
'--bs-btn-font-size': '.75rem',
'--bs-btn-padding-x': '.5rem',
'--bs-btn-padding-y': '.25rem'
}}
theme="primary"
variant="solid"
>
Custom button
</Button>
</div>

Icon buttons

Set the icon prop on Button for a square icon-only button. It sets a 1:1 aspect ratio and removes padding, making the button square based on its minimum height. Always include an aria-label on icon-only buttons for screen reader users.

<div className="d-flex flex-wrap gap-2 align-items-center overflow-auto">
<Button
aria-label="Magic"
icon
>
<Icon
aria-hidden
name="magic"
/>
</Button>
<Button
aria-label="Confirm"
icon
theme="primary"
variant="solid"
>
<Icon
aria-hidden
name="check2"
/>
</Button>
<Button
aria-label="Auto theme"
icon
theme="secondary"
variant="outline"
>
<Icon
aria-hidden
name="circle-half"
/>
</Button>
<Button
aria-label="Light theme"
icon
theme="warning"
variant="subtle"
>
<Icon
aria-hidden
name="sun-fill"
/>
</Button>
</div>

Combine with the size prop for different icon button sizes:

<div className="d-flex flex-wrap gap-2 align-items-center overflow-auto">
<Button
aria-label="Confirm"
icon
size="xs"
theme="primary"
variant="solid"
>
<Icon
aria-hidden
name="check2"
/>
</Button>
<Button
aria-label="Confirm"
icon
size="sm"
theme="primary"
variant="solid"
>
<Icon
aria-hidden
name="check2"
/>
</Button>
<Button
aria-label="Confirm"
icon
theme="primary"
variant="solid"
>
<Icon
aria-hidden
name="check2"
/>
</Button>
<Button
aria-label="Confirm"
icon
size="lg"
theme="primary"
variant="solid"
>
<Icon
aria-hidden
name="check2"
/>
</Button>
</div>

Disabled state

Set the disabled prop on Button to prevent interaction and apply disabled styling. Native button elements also prevent activation when disabled.

<div className="d-flex flex-wrap gap-2 overflow-auto">
<Button
disabled
theme="primary"
variant="solid"
>
Primary button
</Button>
<Button
disabled
theme="secondary"
variant="solid"
>
Button
</Button>
<Button
disabled
theme="primary"
variant="outline"
>
Primary button
</Button>
<Button
disabled
theme="secondary"
variant="outline"
>
Button
</Button>
</div>

When Button renders as a link, its disabled prop removes navigation and keyboard focus as well as applying disabled styling.

<div className="d-flex flex-wrap gap-2 align-items-center overflow-auto">
<Button
aria-disabled="true"
disabled
href="#"
theme="primary"
variant="solid"
>
Primary link
</Button>
<Button
aria-disabled="true"
disabled
href="#"
theme="secondary"
variant="solid"
>
Link
</Button>
</div>

If there’s an href attribute, add tabindex="-1" and aria-disabled="true" to prevent keyboard focus and assistive technologies from interacting with the link.

<div className="d-flex flex-wrap gap-2 align-items-center overflow-auto">
<Button
aria-disabled="true"
disabled
href="#"
tabIndex={-1}
theme="primary"
variant="solid"
>
Primary link
</Button>
<Button
aria-disabled="true"
disabled
href="#"
tabIndex={-1}
theme="secondary"
variant="solid"
>
Link
</Button>
</div>

You may also want to use custom JavaScript to disable the link functionality altogether.

In these React examples, disabled handles this for you: Button removes the link destination, prevents navigation, and supplies aria-disabled and tabIndex={-1}.

Block buttons

Use a grid container with gap utilities passed through className to create a vertical stack of full-width buttons.

<div className="d-flex flex-wrap gap-2 align-items-center overflow-auto">
<div className="d-grid gap-2">
<Button
theme="primary"
variant="solid"
>
Button
</Button>
<Button
theme="primary"
variant="solid"
>
Button
</Button>
</div>
</div>

This responsive variation changes from a vertical stack to a horizontal layout at the md breakpoint. Resize your browser to see the layout change.

<div className="d-flex flex-wrap gap-2 align-items-center overflow-auto">
<div className="d-grid gap-2 md:d-block">
<Button
theme="primary"
variant="solid"
>
Button
</Button>
<Button
theme="primary"
variant="solid"
>
Button
</Button>
</div>
</div>

Use a Col with xs={6} to constrain the button stack to half the available width, and center it with margin utilities passed through className.

<div className="d-flex flex-wrap gap-2 align-items-center overflow-auto">
<Col
className="d-grid gap-2 mx-auto"
xs={6}
>
<Button
theme="primary"
variant="solid"
>
Button
</Button>
<Button
theme="primary"
variant="solid"
>
Button
</Button>
</Col>
</div>

Additional utilities can be used to adjust the alignment of buttons when horizontal. Here we’ve taken our previous responsive example and added some flex utilities and a margin utility on the button to right-align the buttons when they’re no longer stacked.

<div className="d-flex flex-wrap gap-2 align-items-center overflow-auto">
<div className="d-grid gap-2 md:d-flex md:justify-content-end">
<Button
className="md:me-2"
theme="primary"
variant="solid"
>
Button
</Button>
<Button
theme="primary"
variant="solid"
>
Button
</Button>
</div>
</div>

Toggle buttons

Use ToggleButton to create button-like checkboxes and radio buttons. It provides the button appearance and interaction behavior, and can be grouped in a button group.

Visually, these toggle buttons are identical to our active-state buttons, but are conveyed differently by assistive technologies. Checkbox toggles will be announced by screen readers as "checked"/"not checked" as they are checkboxes under the hood. Active-state buttons are announced as "button"/"button pressed". It’s up to you to decide which approach makes more sense for your use case.

Checkboxes

Checkboxes can be checked, unchecked, or disabled. Checkbox-based toggle buttons only toggle a single button’s state.

<div className="d-flex flex-wrap gap-2 overflow-auto">
<ToggleButton
defaultChecked
theme="primary"
type="checkbox"
variant="solid"
>
Checked
</ToggleButton>
<ToggleButton
theme="primary"
type="checkbox"
variant="solid"
>
Toggle
</ToggleButton>
<ToggleButton
disabled
theme="primary"
type="checkbox"
variant="solid"
>
Disabled
</ToggleButton>
</div>

Radios

Radios can be checked, unchecked, or disabled. Use radio-based toggle buttons to toggle states between a set of buttons that include input elements with the same name attribute value.

<div className="d-flex flex-wrap gap-2 overflow-auto">
<ToggleButton
defaultChecked
name="options"
theme="primary"
type="radio"
variant="solid"
>
Checked
</ToggleButton>
<ToggleButton
name="options"
theme="primary"
type="radio"
variant="solid"
>
Toggle
</ToggleButton>
<ToggleButton
disabled
name="options"
theme="primary"
type="radio"
variant="solid"
>
Disabled
</ToggleButton>
<ToggleButton
name="options"
theme="primary"
type="radio"
variant="solid"
>
Toggle
</ToggleButton>
</div>

Active state

Button does not manage active state. Pass active from application state so the application remains the source of truth.

For toggle semantics, Button sets aria-pressed when active is provided. Buttons without active remain ordinary buttons.

Toggle buttons

Render the active state supplied by your application:

<div className="d-flex flex-wrap gap-2 overflow-auto">
<Button
active={false}
theme="primary"
variant="solid"
>
Inactive toggle button
</Button>
<Button
active
theme="primary"
variant="solid"
>
Active toggle button
</Button>
<Button
active={false}
disabled
theme="primary"
variant="solid"
>
Disabled toggle button
</Button>
</div>
<div className="d-flex flex-wrap gap-2 overflow-auto">
<Button
active={false}
href="#"
theme="primary"
variant="solid"
>
Inactive link button
</Button>
<Button
active
href="#"
theme="primary"
variant="solid"
>
Active toggle link
</Button>
<Button
aria-disabled="true"
disabled
href="#"
theme="primary"
variant="solid"
>
Disabled link button
</Button>
</div>

Because Button defaults to the button role even when href renders an anchor, the active prop also supplies aria-pressed without additional role configuration.

CSS

Variables

Buttons use CSS variables for real-time customization. These are set on the base .btn class and inherited by all button variants.

CSS variableDefault
--bs-btn-gapvar(--bs-btn-input-gap)
--bs-btn-min-heightvar(--bs-btn-input-min-height)
--bs-btn-padding-xvar(--bs-btn-input-padding-x)
--bs-btn-padding-yvar(--bs-btn-input-padding-y)
--bs-btn-font-sizevar(--bs-btn-input-font-size)
--bs-btn-font-weightvar(--bs-btn-input-font-weight)
--bs-btn-line-heightvar(--bs-btn-input-line-height)
--bs-btn-colorvar(--bs-fg-body)
--bs-btn-white-spacenowrap
--bs-btn-border-widthvar(--bs-border-width)
--bs-btn-border-colortransparent
--bs-btn-border-radiusvar(--bs-radius-5)
--bs-btn-hover-border-colortransparent
--bs-btn-disabled-opacity0.65
--bs-btn-transition-propertycolor, background-color, border-color, box-shadow
--bs-btn-transition-duration0.15s
--bs-btn-transition-timingease-in-out

The variant prop updates these variables according to the selected theme, allowing buttons to adapt automatically to their theme color.

Styled buttons use local CSS variables.

CSS variableDefault
--bs-btn-gradient-startrgba(255, 255, 255, 0.125)
--bs-btn-gradient-endrgba(0, 0, 0, 0.075)
--bs-btn-border-mix-color#000
--bs-btn-border-mix-amount10%
--bs-btn-border-hover-mix-amount12.5%
--bs-btn-border-active-mix-amount20%
--bs-btn-shadow0 1px 2px rgb(0 0 0 / 15%), inset 0 1px 0 rgb(255 255 255 / 10%)
--bs-btn-active-shadowinset 0 2px 4px rgba(0, 0, 0, 0.15)

Link buttons use local CSS variables.

CSS variableDefault
--bs-btn-font-weightvar(--bs-btn-input-font-weight)
--bs-btn-colorvar(--bs-fg-body)
--bs-btn-bgvar(--bs-theme-bg)
--bs-btn-border-colortransparent
--bs-btn-hover-coloroklch(from var(--bs-theme-contrast) calc(l * .95) calc(c * 1.1) h)
--bs-btn-hover-bgoklch(from var(--bs-theme-bg) calc(l * .95) calc(c * 1.1) h)
--bs-btn-hover-border-colortransparent
--bs-btn-active-coloroklch(from var(--bs-theme-contrast) calc(l * .9) calc(c * 1.15) h)
--bs-btn-active-bgoklch(from var(--bs-theme-bg) calc(l * .9) calc(c * 1.15) h)
--bs-btn-active-border-coloroklch(from var(--bs-theme-bg) calc(l * .9) calc(c * 1.15) h)
--bs-btn-disabled-colorvar(--bs-theme-contrast)
--bs-btn-disabled-border-colorvar(--bs-theme-bg)
Documentation navigation
On this page
On this page