Button #
The va-button
component replaces the standard HTML button. It offers multiple built-in style presets and allows user to change different attributes (size, color, opacity etc.) manually.
Examples #
Default #
Just a simple button.
Presets #
The preset
prop is used to change the build-in style of the component.
Colors #
The color
prop is used to change the color of the component.
Gradient #
Used to apply a gradient style to a background (only if backgroundOpacity
prop is equals 1
).
Text colors #
The text-color
prop is used to change the color of the button description.
Sizes #
The size
prop is used to fit your button to any place on your web page.
Rounded #
You can make your button rounded using round
prop.
Outlined #
You can make the button outlined using prop border-color
.
Add icons #
You can add icons to va-button
with 2 different props: icon
and icon-right
. Also you can specify color for them via icon-color
prop.
Loading state #
You can add loading state to the button.
Behavior #
You can change hover or pressed behavior of the button via hover
/pressedBehavior
, hover
/pressedMaskColor
and hover
/pressedOpacity
props.
Disabled #
The disabled
prop prevents any actions with button.
Tag #
You can change the tag of the button wrapper to any other necessary one. However, we recommend to use other properties. For example, if the href
property is set, then button
will be replaced with a
, and if the value of the to
property is passed, the button tag will automatically change to router-link
.
API #
Props #
Name | Description | Types | Default |
---|---|---|---|
activeClass | Applied when the link is active. More info here. |
| - |
append | When set, always appends the relative path to the current path. More info here. |
| - |
backgroundOpacity | Sets up button background opacity. |
|
|
block | Applies block styling (will take 100% of container width). |
|
|
borderColor | Color CSS style |
|
|
color | Color of the component (theme string or |
|
|
disabled | Applies |
|
|
exact | Exactly match the link. Without this, '/' will match every route. More info here. |
| - |
exactActiveClass | Applied when the link is active with exact match. More info here. |
| - |
fontSizesConfig | Provide a set of sizes for fonts as a global component specific setting. |
|
|
gradient | Makes the button background color a gradient (only if |
|
|
hoverBehavior | Behavior of the button, when it's being hovered. Can be |
|
|
hoverMaskColor | Mask color for |
|
|
hoverOpacity | Opacity value for |
|
|
href | Will be used as value for html |
| - |
icon | The icon to be displayed to the left of the title. |
|
|
iconColor | Sets an icon color. |
|
|
iconRight | The icon to be displayed to the right of a title. |
|
|
loading | Indicates that something is loading (spinner icon). |
|
|
plain | Applies |
|
|
preset | Named preset combination of component props. |
| - |
pressedBehavior | Behavior of the button, when it's being pressed. Can be |
|
|
pressedMaskColor | Mask color for |
|
|
pressedOpacity | Opacity value for |
|
|
replace | When set, calls |
| - |
round | Adds rounded corners (or make a button fully rounded if only icon is passed). |
|
|
size | Specify size for component. |
|
|
sizesConfig | Provide a set of sizes as a global component specific setting. |
|
|
tag | Replaces html tag. This is useful for semantics and also to allow for valid markup in some cases ( |
|
|
target | Will be used as value for html |
| - |
textColor | Text color (theme string or HEX string). |
|
|
textOpacity | Sets button text opacity. |
|
|
to | The target route of the link. More info here. |
| - |
type | Will be used as value for html |
|
|
Events #
Name | Description |
---|---|
click | Emitted when user clicks on button. The event argument is:
|
Slots #
Name | Description |
---|---|
append | Slot to input before button's content. Slot scope properties available: |
default | Default slot for button's content. |
loading | Slot for loading state. Slot scope properties available: |
prepend | Slot to input after button's content. Slot scope properties available: |
Methods #
Name | Description |
---|---|
blur | Removes focus from button |
focus | Sets focus on button |
Css Variables #
Name | Default Value |
---|---|
--va-button-display | inline-flex |
--va-button-justify-content | center |
--va-button-align-items | center |
--va-button-background-image | none |
--va-button-box-shadow | none |
--va-button-border-width | 0 |
--va-button-border-color | unset |
--va-button-border-style | none |
--va-button-font-weight | 600 |
--va-button-transition | none |
--va-button-padding | 0 |
--va-button-cursor | pointer |
--va-button-sm-size | 1.5rem |
--va-button-sm-content-py | 0.25rem |
--va-button-sm-content-px | 0.375rem |
--va-button-sm-only-icon-content-px | 0.25rem |
--va-button-sm-font-size | 0.8125rem |
--va-button-sm-letter-spacing | 0 |
--va-button-sm-line-height | 1rem |
--va-button-sm-border-radius | 0.125rem |
--va-button-sm-icon-side-padding | var(--va-button-sm-content-py) |
--va-button-sm-icons-spacing | 0.125rem |
--va-button-size | 2.25rem |
--va-button-content-py | 0.5rem |
--va-button-content-px | 0.75rem |
--va-button-only-icon-content-px | 0.5rem |
--va-button-font-size | 1rem |
--va-button-letter-spacing | 0 |
--va-button-line-height | 1.25rem |
--va-button-border-radius | 0.25rem |
--va-button-icon-side-padding | var(--va-button-content-py) |
--va-button-icons-spacing | 0.25rem |
--va-button-lg-size | 3rem |
--va-button-lg-content-py | 0.75rem |
--va-button-lg-content-px | 1rem |
--va-button-lg-only-icon-content-px | 1rem |
--va-button-lg-font-size | 1.05rem |
--va-button-lg-letter-spacing | 0 |
--va-button-lg-line-height | 1.5rem |
--va-button-lg-border-radius | 0.5rem |
--va-button-lg-icon-side-padding | var(--va-button-lg-content-py) |
--va-button-lg-icons-spacing | 0.25rem |
--va-button-bordered-border | 1px |
--va-button-bordered-style | solid |