This page as markdown: /button.md · Index for agents: /llms.txt · Everything in one file: /llms-full.txt

Button

Status: stable

Pill-shaped action primitive (theme-driven radius via --button-radius, defaults to full). Neutral tiers (primary/secondary/ghost/outline), plus destructive and link, and three on-color tiers (on-color/on-color-outline/on-color-ghost) that paint with the surrounding ink so a button reads on any tone or brand fill. Optional loading state shows a spinner and disables the button.

Keywords: button, action, cta, submit, save, cancel, destructive, loading, link, icon button, on color, inverse, band, brand fill, tone fill, bleed, optical alignment, align label to edge, negative margin, view all

Usage

Use Button when the user commits an action, submits a form, opens UI, or confirms a decision. Use the visual tier to communicate priority: one primary action per local decision area, then secondary, ghost, outline, or link for lower-emphasis choices.

Best practices

Anatomy

Part Required Description
Container yes The rounded hit target that carries the visual tier, focus ring, disabled state, and loading affordance.
Label yes Visible action text and the default accessible name. Icon-only buttons still need an aria-label.
Leading icon no An optional semantic Icon that reinforces the label without replacing it.
Spinner no Displayed during loading and paired with aria-busy plus disabled activation.

Props

Name Type Default Description
variant "primary" | "secondary" | "ghost" | "outline" | "destructive" | "link" | "floating" | "field" | "on-color" | "on-color-outline" | "on-color-ghost" "primary" Visual emphasis tier. One primary per screen. The on-color tiers are for buttons ON a coloured fill: they paint with the inherited text colour (the fill's ink) — on-color is solid (ink background, fill-coloured label via the optional --on-color-fill var, else black/white), on-color-outline and on-color-ghost are transparent with an ink label. Never use them on page or card surfaces. floating is for a control that sits OVER content (carousel arrows, a marquee pause, a jump-to-latest over a conversation): its own edge, lift and translucent popover fill, so it reads on arbitrary content beneath. field is for a button docked in a workspace panel among xs fields: the inset panel-field fill and the field's corner, so a picker trigger or an add action reads as one of the row's controls; pair it with size xs or icon-xs.
size "xs" | "sm" | "md" | "cta" | "icon" | "icon-sm" | "icon-xs" "md" Reads the density ladder, so every value differs by register: page 28/32/40/44, workspace 24/28/32/36. xs and icon-xs were added in 0.31.0 for the workspace control floor and are the sizes tool chrome wants; md is the default everywhere. icon/icon-sm/icon-xs are square.
render ReactElement | (props, state) => ReactElement — Compose with another element/component through the Base UI render prop.
loading boolean false Show a Spinner while an action is in flight and refuse presses. The spinner takes the iconStart slot when there is one; otherwise it lays over the label, which fades out in place, so the button keeps its width. Sets aria-busy and aria-disabled, never the native disabled: disabling the focused button sent focus to , so a sheet the action opened had nowhere to return it.
onClick (event: MouseEvent) => unknown — May return a promise: the button shows loading until it settles and ignores further presses meanwhile, from the first click on. Prefer it to a busy flag in state, which takes effect a render late (three fast clicks ran three times).
badge ReactNode — A corner indicator (usually or a count) overlaid on the top-end corner of the glyph. For icon-only sizes; never hand-position a badge over a Button with absolute offsets.
loadingLabel ReactNode — Optional text shown in place of children while loading, with the spinner beside it. The width follows the new text, so prefer no loadingLabel where the row must not move.
iconStart ReactNode — Icon before the label. The button takes one 2px step off its start padding so icon + label read as centred. Replaced by the spinner while loading.
iconEnd ReactNode — Icon after the label (disclosure, external link, next). Same optical correction on the end side.
bleed "start" | "end" | "both" | "none" — Optical alignment for a borderless button (ghost, link, on-color-ghost): a negative inline margin of exactly its own padding on that side — --button-px, or the icon side's optical padding when an icon sits there; an icon-only size bleeds by its inset to the glyph — so the label (or glyph) lands on the content edge. Hit area and hover/focus fill keep their full size. Logical sides, so it mirrors in RTL. A no-op on variants with a visible edge (primary, secondary, outline, destructive, floating, field, on-color, on-color-outline): a filled button aligns its edge, not its label. Unset, a borderless button renders data-bleed="auto" and SectionHeader, PageHeader and CardAction bleed it when it is their outermost child; none opts out.

Variants

  • variant: primary, secondary, ghost, outline, destructive, link, floating, field, on-color, on-color-outline, on-color-ghost
  • size: xs, sm, md, cta, icon, icon-sm, icon-xs

Tokens used

primary, primary-foreground, secondary, secondary-foreground, accent, accent-foreground, input, destructive, destructive-foreground, ring, panel-field, panel-field-hover, panel-foreground

Motion

  • arrival · Root · no motion — A button belongs to the layout it ships in. Whatever staged that region owns the entrance; a button that fades in on its own is a button that is briefly un-clickable for no stated reason.
  • response · Root · motion-interactive — Hover, focus ring and disabled fade all ease on one declaration. This is the reference case for the whole recipe: it lists scale and translate alongside the colours specifically so motion-press can add a transform without a second, conflicting transition-property.
  • response · Root · motion-press — The 0.97 settle on pointer-down is the only confirmation the press registered before the action's own result arrives — which on a slow network is the difference between waiting and clicking again. It skips disabled elements, so a dead button stays visibly dead.
  • transition · Spinner · motion-appear — Going busy is the one state change a button has. The spinner fades in where it mounts — in the icon slot, or laid over a plain label that fades out beneath it and keeps its place — so the width never changes and the row does not shift under the pointer that just pressed it. The label fades back when the work settles. A toggling control is a Switch or a Toggle; those carry their own transition.
  • activity · Root · no motion — Pending work is passed in via loading, which renders a Spinner — the activity motion lives there rather than being duplicated here.

Accessibility

Related

  • Components: Menu, OverflowMenu, Icon, Banner
  • Patterns: SettingsPage, AuthPage, DashboardPage

Examples

Primary

import { Button } from "@sableui/react"

<Button>Save changes</Button>

Secondary + ghost

import { Button, Row } from "@sableui/react"

<Row gap={1}><Button variant="secondary">Cancel</Button><Button variant="ghost">Skip</Button></Row>

Loading

import { Button } from "@sableui/react"

<Button loading loadingLabel="Saving…">Save</Button>

Main action with options

import { Button, Icon, Menu, MenuContent, MenuItem, MenuTrigger, Row } from "@sableui/react"

<Row gap={2}><Button onClick={deploy}>Deploy</Button><Menu><MenuTrigger render={<Button variant="secondary" size="icon" aria-label="Deploy options"><Icon name="chevron-down" /></Button>} /><MenuContent align="end"><MenuItem>Deploy to preview</MenuItem><MenuItem>Deploy to production</MenuItem></MenuContent></Menu></Row>

Copy to clipboard

import { Button, Icon, Row, useCopy } from "@sableui/react"

const { copy, copied } = useCopy(address)
<Row gap={1}><Button variant="ghost" size="icon-sm" aria-label="Copy address" onClick={copy}><span aria-hidden="true" className="motion-icon-swap"><span data-active={!copied} className="inline-flex"><Icon name="copy" /></span><span data-active={copied} className="inline-flex"><Icon name="check" /></span></span></Button><span role="status" className="sr-only">{copied ? "Copied" : ""}</span></Row>

As link

import { Button } from "@sableui/react"

<Button render={<a href="/explore" />}>Explore</Button>

Primary + secondary decision row

import { Button, Row } from "@sableui/react"

<Row gap={1}><Button>Publish</Button><Button variant="secondary">Save draft</Button><Button variant="ghost">Cancel</Button></Row>

Destructive with confirmation copy

import { Button, Row } from "@sableui/react"

<Row gap={1}><Button variant="secondary">Cancel</Button><Button variant="destructive">Delete project</Button></Row>

Leading icon

import { Button, Icon } from "@sableui/react"

<Button iconStart={<Icon name="plus" />}>New project</Button>

Trailing icon

import { Button, Icon } from "@sableui/react"

<Button variant="secondary" iconEnd={<Icon name="chevron-right" />}>Continue</Button>

Both icons

import { Button, Icon } from "@sableui/react"

<Button variant="outline" iconStart={<Icon name="file" />} iconEnd={<Icon name="chevron-down" />}>Export</Button>

Icon-only

import { Button, Icon } from "@sableui/react"

<Button size="icon" variant="ghost" aria-label="Share"><Icon name="share" /></Button>

Optically aligned to the row's edges

import { Button, Icon, Row, Stack } from "@sableui/react"

<Stack gap={1.5}>
  <Row justify="between">
    <span className="text-title-md">Tasks</span>
    <Button variant="ghost" size="sm" bleed="end">View all</Button>
  </Row>
  <span className="text-body-sm text-muted-foreground">Ship the release notes</span>
  <Button variant="ghost" size="sm" bleed="start" iconStart={<Icon name="plus" />} className="self-start">Add task</Button>
</Stack>

Icon button with an unread badge

import { Button, Icon, NotificationBadge } from "@sableui/react"

<Button size="icon" variant="ghost" aria-label="Notifications" badge={<NotificationBadge dot />}><Icon name="bell" /></Button>

Field button in a panel row

import { Button, Icon, PanelSection, PropertyRow } from "@sableui/react"

<PanelSection title="Text">
  <PropertyRow label="Font">
    <Button variant="field" size="xs" className="w-full justify-between" iconEnd={<Icon name="chevron-down" />}>Figtree</Button>
  </PropertyRow>
</PanelSection>

On a coloured band

import { Button } from "@sableui/react"

<div className="flex gap-3 bg-tone-info p-6 text-tone-info-foreground [--on-color-fill:var(--tone-info)]"><Button variant="on-color">Join the beta</Button><Button variant="on-color-outline">Read the notes</Button></div>

Action in a solid Banner

import { Banner, Button } from "@sableui/react"

<Banner tone="warning" appearance="solid" action={<Button variant="on-color" size="sm">Reconnect</Button>}>Calendar sync paused.</Banner>