Components

Button

A button that can show a loading state during async operations.

An accessible button element with built-in support for disabled, loading, and async click states. Renders as <button> by default but can be any element or component.

Anatomy

  • #default — the button's label or content
  • #loading — content shown while loading (defaults to a spinner)

Usage

Examples

Disabled state

<template>
  <Button disabled>Unavailable</Button>
</template>

Async loading

Use loading-auto to automatically show a spinner while the click handler's Promise is pending.

<script setup lang="ts">
async function save() {
  await api.save();
}
</script>

<template>
  <Button loading-auto :on-click="save">Save</Button>
</template>

Custom loading content

<template>
  <Button :loading="isSaving">
    Save
    <template #loading>
      <span>Saving…</span>
    </template>
  </Button>
</template>
<template>
  <Button as="a" href="/docs">Read the docs</Button>
</template>

Focusable when disabled

Keeps the button in the tab order while disabled — useful for showing tooltips on disabled buttons.

<template>
  <Button disabled focusable-when-disabled>Restricted</Button>
</template>

API Reference

Props

PropTypeDefaultDescription
asstring | Component"button"Element or component to render as.
type"button" | "submit" | "reset""button"HTML button type. Only applied when as="button".
disabledbooleanfalseDisables the button.
focusableWhenDisabledbooleanfalseKeep button focusable while disabled.
loadingbooleanfalseShow the loading state manually.
loadingAutobooleanfalseAutomatically show loading while onClick's Promise resolves.
onClick(event: MouseEvent) => void | Promise<void>Async-aware click handler for loadingAuto.

Slots

SlotScoped propsDescription
defaultButton label / content.
loadingContent shown during the loading state. Defaults to a spinner icon.

Emits

EventPayloadDescription
clickMouseEventFired on click (in addition to native click).