Button
Button or anchor
Three variants, one job each: solid is the action, outline is the alternative beside it, and ghost is the tertiary thing that you otherwise make a link. Color means chosen. Every button is ink at rest and fills with the accent while pressed, so the main action stands out by being solid, not by color. Hover fades and leans. Focus leans with the accent ring. Pressing fills. color="accent" is for a button that shows something already chosen. For a choice that stays on, use Toggle, which carries aria-pressed and fills itself. Use danger for destructive actions. If you can undo the action, do it and offer Undo from a Toaster instead of asking first. Use text (default) for the rest. type defaults to button, so a button inside a form does not submit by accident. For a submit button, say type="submit".
href renders an <a> (or your router's link) with the same look. disabled on a link is enforced: no navigation, out of the tab order. loading shows a spinner, sets aria-busy and ignores clicks while keeping focus, so a keyboard user stays on the button they pressed. A disabled or loading button does not pass its click on to your @click. block fills the container. icon makes the padding square for an icon-only button. Give it an aria-label.
<template>
<div class="row">
<BlessButton>Solid</BlessButton>
<BlessButton variant="outline">Outline</BlessButton>
<BlessButton variant="ghost">Ghost</BlessButton>
<BlessButton color="danger">Danger</BlessButton>
<BlessButton variant="outline" color="danger">Outline danger</BlessButton>
</div>
</template>
<script setup lang="ts">
import { BlessButton } from "blessing-ui";
</script><template>
<div class="row">
<BlessButton size="sm">Small</BlessButton>
<BlessButton size="md">Medium</BlessButton>
<BlessButton size="lg">Large</BlessButton>
</div>
</template>
<script setup lang="ts">
import { BlessButton } from "blessing-ui";
</script><template>
<div class="row">
<BlessButton href="#">Link</BlessButton>
<BlessButton disabled>Disabled</BlessButton>
<BlessButton loading>Saving</BlessButton>
<BlessButton><template #prefix>▶</template>Play</BlessButton>
<BlessButton icon aria-label="Settings" variant="outline">⚙</BlessButton>
<BlessButton href="#" disabled>Disabled link</BlessButton>
</div>
<BlessButton block style="margin-top: 12px">Block — full width</BlessButton>
</template>
<script setup lang="ts">
import { BlessButton } from "blessing-ui";
</script>Usage
import { BlessButton } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
variant | "solid" | "outline" | "ghost" | "solid" | |
color | "text" | "accent" | "danger" | "text" | |
size | "md" | "sm" | "lg" | "md" | |
href | string | — | renders <a> when set |
disabled | boolean | — | |
loading | boolean | — | |
type | "submit" | "button" | "reset" | "button" | |
block | boolean | — | full width of its container |
icon | boolean | — | icon-only: equal padding all round — pass an aria-label |
Events
| Name | Payload | Description |
|---|---|---|
click | [e: MouseEvent] |
Slots
| Name | Scope | Description |
|---|---|---|
prefix | — | |
default | — | |
suffix | — |