Buttons
Vue Bootstrap 5 Buttons component
Use MDB custom button styles for actions in forms, dialogs, and more with support for multiple sizes, states, and more.
Note: Read the API tab to find all available options and advanced customization
Basic example
Disable text wrapping
If you don’t want the button text to wrap, you can add the
.text-nowrap
> class to the button. In Sass, you can set
$btn-white-space: nowrap
> to disable text wrapping for each button.
Hierarchy
Buttons, as one of the key UI elements, must have their own hierarchy. This means that the user should be able to easily identify which button is the most important (primary button), which is less important (secondary button) and which presents completely additional information (tertiary button).
Elements with strong, filled backgrounds and shadows attract attention the most, which is why button primary is built in this way.
A delicate background without shadows is less engaging, so it is well suited for button secondary.
The lack of background and shadow makes the element the least visible. These features characterize the button tertiary.
Note: Button tertiary may require additional margins. Without extra margins, the button edge will be flush with adjacent elements (which is sometimes the desired result). If you need margin - simply add margin utility classes like mx-2
.
Hierarchy
MDB includes several predefined button styles, each serving its own semantic purpose.
Conveying meaning to assistive technologies:
Using color to add meaning only provides a visual indication, which will not be conveyed to
users of assistive technologies – such as screen readers. Ensure that information denoted by
the color is either obvious from the content itself (e.g. the visible text), or is included
through alternative means, such as additional text hidden with the
.visually-hidden
class.
Neutral
Neutral buttons provide additional light and dark colors.
Link
Link button is similar to the tertiary button (and often is used as a substitute). The difference is, that the link button has a background on hover and also has a default padding.
Outline
In need of a button, but not the hefty background colors they bring? Add
outline
property to remove all background images and colors on any button.
Some of the button styles use a relatively light foreground color, and should only be used on a dark background in order to have sufficient contrast.
Rounded
Add rounded
property to make the button rounded.
Rounded outline
You can use outline
and rounded
properties together to make the
button outline and rounded at the same time.
Floating
Use floating
property to make a circle button.
To make it works properly you have to put an icon inside. The text will not fit in. You can find hundreds of available icons in our icons docs.
You can apply almost all the same classes and attributes to the floating buttons as to the regular buttons - colors, ripples, sizes, outline, etc.
Sizes
Fancy larger or smaller buttons? Add size="lg"
or size="sm"
for
additional sizes.
Active state
Add .active
class to make the button look pressed.
Disabled state
Make buttons look inactive by adding the disabled
boolean attribute to any
MDBBtn
element. Disabled buttons have pointer-events: none
applied
to, preventing hover and active states from triggering.
Disabled MDBBtn using the a
tag behave a bit different:
-
<a>
s don’t support thedisabled
attribute, so you must add the.disabled
class to make it visually appear disabled. -
Some future-friendly styles are included to disable all
pointer-events
on anchor buttons. In browsers which support that property, you won’t see the disabled cursor at all. -
Disabled buttons should include the
aria-disabled="true"
attribute to indicate the state of the element to assistive technologies.
Link functionality caveat:
The .disabled
class uses pointer-events: none
to try to disable the
link functionality of <a>
s, but that CSS property is not yet standardized.
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, add a
tabindex="-1"
attribute on these links (to prevent them from receiving keyboard
focus) and use custom JavaScript to disable their functionality.
Toggle states
Add toggler<
> and v-model:toggle<
> props to toggle a button’s
active<
> state.
Buttons - API
Import
Properties
Property | Type | Default | Description |
---|---|---|---|
color |
String | "" |
Changes button color |
size |
String | "" |
Changes button size |
outline |
String | "" |
Changes button style and color to outline |
rounded |
Boolean | false |
Changes button style to rounded |
floating |
Boolean | false |
Changes button style to floating |
toggler |
Boolean | false |
Enables toggling |
toggle |
Boolean | false |
Defines toggle state |
role |
String | "button" |
Defines button's role |
ripple |
[Object, Boolean] | true |
Defines
ripple
configuration or disables it if false .
|
type |
String | "button" |
Defines button's type |
tag |
String | "button" |
Defines button's tag |
Events
Event type | Description |
---|---|
toggle |
Fires immediately when the toggler button is clicked. Returns toggle state (true/false). |
CSS variables
As part of MDB’s evolving CSS variables approach, buttons now use local CSS variables on
.btn
for enhanced real-time customization. Values for the CSS variables are set
via Sass, so Sass customization is still supported, too.
Button's CSS variables are in different classes which belong to this component. To make it easier to use them, you can find below all of the used CSS variables.