Button
General-purpose trigger for in-page actions (toolbars, forms, cards, action bars).
// Radix — @radix-ui/react-slot
import { Button } from "@shavin/ui";Variants
solid (default), soft, outline and ghost, in the default brand tone.
<Button variant="solid">Solid</Button>
<Button variant="soft">Soft</Button>
<Button variant="outline">Outline</Button>
<Button variant="ghost">Ghost</Button>Danger tone
Use tone="danger" for destructive actions.
<Button variant="solid" tone="danger">Delete budget</Button>
<Button variant="soft" tone="danger">Delete budget</Button>
<Button variant="outline" tone="danger">Delete budget</Button>
<Button variant="ghost" tone="danger">Delete budget</Button>Sizes
<Button size="sm">Small</Button>
<Button size="md">Medium</Button>
<Button size="lg">Large</Button>Disabled
<Button disabled>Solid</Button>
<Button variant="soft" disabled>Soft</Button>
<Button variant="outline" disabled>Outline</Button>
<Button variant="ghost" disabled>Ghost</Button>Disabled with a reason
disabledReason keeps the button focusable (aria-disabled) and shows why in a Tooltip on hover, keyboard focus and tap. Plain disabled gives no reason: prefer this for permission or plan limits.
<Button variant="outline" disabledReason="Upgrade to Pro to export">Export CSV</Button>
<Button disabledReason="Add a title first">Publish</Button>Loading
While a request runs: the spinner replaces the left icon (or covers the label), the width stays, the button stays focusable with the progress cursor, and clicks are ignored. loadingLabel swaps the text and is announced.
<Button loading>Save changes</Button>
<Button loading loadingLabel="Saving…" iconLeft={<Icon name="save" size="sm" />}>Save changes</Button>
<Button variant="outline" loading>Refresh</Button>With icons
iconLeft and iconRight take any node. Use Icon.
<Button iconLeft={<Icon name="plus" size="sm" />}>Add expense</Button>
<Button variant="outline" iconRight={<Icon name="arrow-right" size="sm" />}>Continue</Button>
<Button variant="soft" iconLeft={<Icon name="download" size="sm" />}>Export CSV</Button>Icon-only actions
A button with no visible label is an IconButton. aria-label is required.
<IconButton variant="ghost" aria-label="Search transactions">
<Icon name="search" size="sm" />
</IconButton>
<IconButton variant="outline" aria-label="Notifications">
<Icon name="bell" size="sm" />
</IconButton>As a link
asChild passes the button styles to its single child through Radix Slot. Use it for navigation, so the element stays a link.
<Button asChild variant="outline">
<a href="#monthly-report">View monthly report</a>
</Button>Text truncation
truncate is on by default and cuts long labels with an ellipsis. Set truncate={false} to wrap.
<div className="w-40">
<Button truncate iconLeft={<Icon name="plus" size="sm" />}>Add recurring household expense</Button>
</div>
<div className="w-40">
<Button truncate={false} iconLeft={<Icon name="plus" size="sm" />}>Add recurring household expense</Button>
</div>Best practices
| Do | Use variant='solid' tone='brand' for primary action in a container or form. |
| Do | Use variant='ghost' or variant='soft' for secondary/toolbar actions to preserve visual hierarchy. |
| Do | Disable a submit only while its request runs (loading), not while the form is incomplete. |
| Do | Use disabledReason for actions blocked by permission or plan ('Upgrade to Pro to export'); print long reasons as text next to the button too. |
| Don't | Do not use plain disabled without saying why: use disabledReason, or a hint next to it. |
| Don't | Do not place two solid brand buttons adjacent to each other in the same action bar. |
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| asChild | boolean | — | — |
| truncate | boolean | true | Whether text label truncates with ellipsis if container space is constrained. Default true. |
| iconLeft | ReactNode | — | Icon rendered before the label. Size it to the text (e.g. an h-4 w-4 svg). |
| iconRight | ReactNode | — | Icon rendered after the label. |
| loading | boolean | — | Pending state while a request runs: a Spinner replaces `iconLeft` (or covers the label when there is no icon), the width does not change, `aria-busy`, clicks are ignored, the button stays focusable and shows the progress cursor. Not dimmed: it is busy, not unavailable. |
| loadingLabel | string | — | Optional text shown and announced (polite) while `loading`, e.g. "Saving…". |
| disabledReason | string | — | Why the action is unavailable ("Upgrade to Pro to export"). Renders the button `aria-disabled` (not `disabled`) so it stays focusable and hoverable, with the reason in a Tooltip on hover and keyboard focus, on tap for touch, and as its accessible description. Clicks do nothing. Takes precedence over `disabled`. |
| variant | "solid" | "soft" | "outline" | "ghost" | "solid" | — |
| tone | "brand" | "danger" | "brand" | — |
| size | "sm" | "md" | "lg" | "md" | — |