Skip to content

Button Component

Button Component

Buttons are used to trigger an immediate action, marking one (or encapsulating a group of) action commands, responding to user click behavior, and triggering corresponding business logic.

Basic Usage

Buttons have six types: default button, primary button, success button, info button, warning button, danger button, and text button.

Show CodeArrow
CopyGitHub

Disabled State

Button unavailable state. Disable the button by setting the disabled attribute to true.

Show CodeArrow
CopyGitHub

Icon Button

Buttons with icons can enhance button recognizability. Use prefixIcon and suffixIcon attributes to set prefix and suffix icons respectively.

Show CodeArrow
CopyGitHub

Loading State

After clicking the button to perform data loading operations, display the loading state on the button. Show the loading state by setting the loading attribute to true.

Show CodeArrow
CopyGitHub

Button Size

The Button component provides three sizes: large button, default button, and small button. Control the button size by setting the size attribute.

Show CodeArrow
CopyGitHub

Button Radius

Control the button's border radius style by setting the radius attribute, providing three border radius types: default, round, and circle.

Show CodeArrow
CopyGitHub

Custom Color

You can customize the button's theme color through the color attribute.

Show CodeArrow
CopyGitHub

Scale Effect

Buttons have a click scale effect by default. You can disable this effect by setting the scale attribute to false.

Show CodeArrow
CopyGitHub

Button API

Attributes

AttributeDescriptionTypeAccepted ValuesDefault
typeButton typestringdefault / primary / success / warning / danger / info / textdefault
sizeButton sizestringlarge / default / smalldefault
disabledWhether disabledbooleantrue / falsefalse
loadingWhether loadingbooleantrue / falsefalse
prefixIconPrefix iconstring
suffixIconSuffix iconstring
radiusButton border radius typestringdefault / round / circledefault
colorCustom button colorstring
scaleWhether to enable scale effectbooleantrue / falsetrue
htmlTypeNative button typestringbutton / submit / resetbutton

Events

Event NameDescriptionParameters
clickTriggered when button is clicked(event: MouseEvent)

Slots

Slot NameDescription
defaultButton content

Style Variables

The button component uses the following style variables, which can be customized through SCSS variables:

Variable NameDescription
$theme-color-primaryTheme color - Primary
$theme-color-successTheme color - Success
$theme-color-infoTheme color - Info
$theme-color-warningTheme color - Warning
$theme-color-dangerTheme color - Danger
$color-whiteWhite color
$color-blackBlack color
$text-color-defaultDefault text color
$bg-color-defaultDefault background color
$border-color-defaultDefault border color
$font-size-defaultDefault font size
$font-size-smallSmall font size
$font-size-largeLarge font size
$opacity-disabledDisabled state opacity

Released under the MIT License