Skip to content

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.

Component Source
<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.

Component Source
<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

Component Source
<Button size="sm">Small</Button>
<Button size="md">Medium</Button>
<Button size="lg">Large</Button>

Disabled

Component Source
<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.

Component Source
<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.

Component Source
<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.

Component Source
<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.

Component Source
<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.

Component Source
<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.

truncate (default)
truncate={false}
Component Source
<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

DoUse variant='solid' tone='brand' for primary action in a container or form.
DoUse variant='ghost' or variant='soft' for secondary/toolbar actions to preserve visual hierarchy.
DoDisable a submit only while its request runs (loading), not while the form is incomplete.
DoUse disabledReason for actions blocked by permission or plan ('Upgrade to Pro to export'); print long reasons as text next to the button too.
Don'tDo not use plain disabled without saying why: use disabledReason, or a hint next to it.
Don'tDo not place two solid brand buttons adjacent to each other in the same action bar.

Props

PropTypeDefaultDescription
asChildboolean——
truncatebooleantrueWhether text label truncates with ellipsis if container space is constrained. Default true.
iconLeftReactNode—Icon rendered before the label. Size it to the text (e.g. an h-4 w-4 svg).
iconRightReactNode—Icon rendered after the label.
loadingboolean—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.
loadingLabelstring—Optional text shown and announced (polite) while `loading`, e.g. "Saving…".
disabledReasonstring—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"—
Configure Theme
Theme
Brand Color
Custom
Gray Family
Appearance
Radius
Scaling
Panel Style
Heading Font
Body Font