Skip to content

Button

Common action buttons.

Basic Usage

Use the type prop to define the button type.

Basic Usage

Plain Button

Use the plain prop to set a plain button style.

Plain Button

Round Button

Use the round prop to set rounded button corners.

Round Button

Circle Button

Use the circle prop to create circle buttons, typically used for icon-only buttons.

Circle Button

Disabled

Use the disabled prop to control the disabled state.

Disabled

Loading

Use the loading prop to control the loading state.

Loading

Sizes

Use the size prop to set the button size.

Sizes

Text Button

Use the text prop to set a text-style button.

Text Button

Use the link prop to set a link-style button.

Link Button

Block Button

Use the block prop to create a full-width block button.

Block Button

Custom Color

Use the color prop to customize button colors.

Custom Color

Icon Position

Control the icon position relative to text with the icon-position prop. Supports left (default), right, top, bottom.

Icon Position

Use in Nuxt

The Button component fully supports Nuxt 3/4 SSR rendering. In Nuxt projects, the component is auto-imported without manual registration.

Use in Nuxt

SSR Notes:

  • ✅ All props and styles fully supported
  • ✅ Event bindings work correctly
  • ✅ Slot content fully rendered
  • ✅ Dynamic states (loading, disabled, etc.)
  • ⚠️ autofocus only takes effect on client-side

SSR Safety

The Button component has passed comprehensive SSR testing, ensuring consistent rendering between server and client.

API

Props

PropDescriptionTypeDefault
typeButton type'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info''default'
sizeButton size'large' | 'default' | 'small''default'
disabledWhether disabledbooleanfalse
loadingWhether loadingbooleanfalse
plainWhether plain stylebooleanfalse
roundWhether roundedbooleanfalse
circleWhether circularbooleanfalse
textWhether text buttonbooleanfalse
linkWhether link buttonbooleanfalse
blockWhether block-level buttonbooleanfalse
native-typeNative type attribute'button' | 'submit' | 'reset''button'
autofocusWhether auto-focusbooleanfalse
iconLeft icon componentstring | Component
suffix-iconRight icon componentstring | Component
icon-positionIcon position'left' | 'right' | 'top' | 'bottom''left'
colorCustom button colorstring
tagCustom element tagstring | Component'button'

Events

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

Slots

Slot NameDescription
defaultButton content
iconCustom content (affected by icon-position)
suffixIconIndependent suffix slot (fixed on the right)
loadingCustom loading icon

Expose

NameDescriptionType
refButton DOM element referenceHTMLButtonElement | undefined
sizeComputed actual sizeButtonSize
typeButton typeButtonType
disabledWhether disabledboolean

Theme Variables

The Button component supports customizing local styles by overriding the following CSS variables:

VariableDescriptionDefault
--yh-button-bg-colorButton background colorvar(--yh-fill-color-blank)
--yh-button-text-colorButton text colorvar(--yh-text-color-regular)
--yh-button-border-colorButton border colorvar(--yh-border-color)
--yh-button-hover-bg-colorHover background colorvar(--yh-color-primary-light-9)
--yh-button-hover-text-colorHover text colorvar(--yh-color-primary)
--yh-button-hover-border-colorHover border colorvar(--yh-color-primary-light-8)
--yh-button-active-bg-colorActive/click background colorvar(--yh-color-primary-light-8)
--yh-button-active-border-colorActive/click border colorvar(--yh-color-primary)
--yh-button-active-text-colorActive/click text color

Released under the MIT License.