Button

A React component in Beamline's Actions category, in the free sample.

The action control: five weights and a brand fill, a buy/sell tone, sm/md/lg and a 44 px touch size, icon-only, a loading state that keeps its size and focus, and a label that changes in place.

Use it for

  • Any action that happens on click: submit, save, open, run. One primary (or accent) per view.

Not for

Anatomy

  • root (button, or the child element with asChild)
  • leading icon (any icon element among the children, before the text)
  • label (the text; its width follows the text when it changes; in a room narrower than the button it ends in an ellipsis)
  • loader (a spinner that opens in front of the label while loading)

Variants

  • variant: primary, secondary, outline, ghost, danger, accent
  • size: sm, md, lg, touch (44 px, bottom action bars on phones)
  • shape: text (padding on both sides), icon-only (square; iconOnly, or detected when no words sit anywhere among the children: an icon or a frame of icons; an element with words, like <span>Close</span>, is a label)
  • tone: up (buy: --pui-up fill or label), down (sell: --pui-down fill or label)

States

  • rest
  • hover (arrives at once, leaves over --pui-motion-out)
  • pressed (scale 0.97, icon/sm 0.95, at 0ms; none on popup anchors or with reduced motion)
  • focus (the look's focus ring, never animated)
  • disabled (--pui-opacity-disabled)
  • working (loading: loader opens in front of the label, size and focus kept, aria-busy, clicks ignored)
  • resolved (the caller changes the label in place, e.g. Save → Saved; never reverted by a timer)
  • error (the caller keeps or restores the label and shows the message next to the cause; the button never turns red)

Keyboard

  • Enter / Space activate (native button)
  • Tab focuses; focus stays on the button through loading

Motion

Hover colour arrives at 0ms and leaves over --pui-motion-out. Press scales to 0.97 at once (narrow buttons 0.95) and springs back. A changed label slides up out of a soft blur while the width follows on spring.morph; the loader opens its width from 0 so nothing jumps. Reduced motion: colour changes only, no scale, no slide. When the label changes, the leaving words are hidden from assistive tech at once: the accessible name is the new label the moment it changes, not both while the old one animates away.

Props

PropTypeDefaultDescription
variant"primary" | "secondary" | "outline" | "ghost" | "danger" | "accent""primary"Visual weight: primary (ink-filled), secondary, outline, ghost, danger, or accent (filled with the brand).
size"sm" | "md" | "lg" | "touch""md"Height 32 / 36 / 40 px; touch 44 px for a bottom action bar on a phone.
tone"up" | "down"—Market side. On primary/accent the fill becomes --pui-up (buy) or --pui-down (sell); on the quiet variants the label takes that colour. Pair it with a word or arrow: colour is never the only signal.
loadingboolean—Shows a loader in front of the label, sets aria-busy and ignores clicks; size and focus stay.
look"soft" | "blueprint" | "glass" | "metal" | "glow" | "pop" | "mono" | "ink"—Paint this button in another look than the one in force around it (DESIGN-LANGUAGE.md "Looks").
asChildboolean—Render the single child (a link, a Radix trigger) with the button's look instead of a <button>.
iconOnlyboolean—A square button holding only an icon (give it an aria-label). Decided by the children when left out: icon-only when no words sit anywhere among them (an icon, or a frame of icons), so `<span>Close</span>` is a label.
...button attributesButtonHTMLAttributes—type defaults to "button". Icon-only buttons need aria-label.
classNamesPartial<Record<"root" | "label" | "loader", string>>—Classes for the named visual parts; no overrides by default.
refRef<HTMLButtonElement>—Receives the documented native target or imperative handle; omitted by default.

Built from

Used in

Dependencies

motion, radix-ui

Import

import { Button } from "@beamline/button";

Get it

Button is part of Beamline UI. Install the parts you need in your React app as compiled packages or editable source. Button is included in the free MIT sample. Get Beamline · Connect your agent

More in Actions

  • Consequence preview: A risky action that shows what it will do before it runs: one headline sentence, what blocks it and what it also reaches as bands, then the rest as cards…
  • Theme switch: The light/dark control: the page changes in one of four transitions starting from the button (reveal, eclipse, split, rise), and the icon turns between…
  • Confirm morph: A destructive action that asks in place: the button morphs into its question, then into working, then into the result with Undo or Retry, without a dialog.
  • Swipe actions: Row actions behind a swipe on touch screens and a two-finger swipe on a trackpad, and at the row's end for pointer and keyboard (a ⋯ menu in a narrow…
  • Hold to confirm: Confirms a costly action by holding instead of clicking: a fill sweeps across while held and drains if let go early; pointer, touch, Space and Enter all…
  • Split button: One obvious action joined to a menu of close alternatives; both halves are real buttons and the menu uses the shared menu rows.
  • Copy button: Copies a value and confirms in place: the icon becomes a check and the label says Copied; a refused copy says so instead of pretending.

Guides: React performance lessons from 517 examples · Build your own React UI style with Beamline

Compared in: Beamline UI and Kobra: interaction design and app screens

Part of Beamline UI: polished, editable React components and complete screens for custom applications. Build your own style from any look; tokens, fonts, radii, motion; not only colours.