Hold to confirm

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

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 hold.

Use it for

  • Destructive actions where an accidental click is costly and a dialog would interrupt: delete a workspace, cancel an order.

Not for

  • Frequent actions (the hold becomes a tax).
  • Actions people must be able to do without holding: pair it with another route where that matters (alert-dialog).

Anatomy

  • button
  • fill
  • icon
  • label
  • hint for screen readers

Variants

  • tone: danger, neutral
  • size: sm, md, lg

States

  • idle
  • holding (sinks a little at once; the fill sweeps)
  • let go too soon (the fill runs a little way and back: what holding does)
  • confirmed
  • disabled

Keyboard

  • Hold Space or Enter
  • releasing early cancels

Motion

Held, the control sinks a little at 0 ms (a third of the look's press depth; none under reduced motion) and a fill of the control's own colour (a quarter strength; ink at a seventh for neutral) sweeps from the inline start, linearly, for exactly the hold time, so its edge is the progress; let go early and it drains back over --pui-duration-standard. A press let go within the first quarter shows once what holding does: the fill runs a fifth of the way and back. Confirmed keeps it full and the label slides to the result while the width eases to the new words (useWidthMorph). Reduced motion keeps the sweep (it is information); the drain, the label swap and the width become instant.

Props

PropTypeDefaultDescription
labelstring—Say the hold: "Hold to delete workspace".
confirmedLabelstring"Done"Shown once confirmed. Default "Done".
onConfirm() => void—Runs the confirmation action; required handler.
durationnumber1200How long to hold, ms. Default 1200.
tone"danger" | "neutral""danger"Semantic colour of the displayed content. Defaults to "danger".
confirmedboolean—Confirmed state, controlled; uncontrolled it stays confirmed after the hold.
onHoldChange(holding: boolean) => void—Reports hold state after a change; no callback by default.
style / refCSSProperties / native Ref—style: Inline styles on the documented visual root; no inline overrides by default. ref: Receives the button or trigger; no ref by default.
classNamesHoldToConfirmClassNames—Classes for the named visual parts; no part overrides by default.
iconReactNode—Icon element shown beside the label. Defaults to no leading icon.
sizeButtonSize—Control size within the supported size steps. Defaults to "md".
disabledboolean—Prevents interaction with the control. Defaults to false.
classNamestring—Classes on the documented visual root; no override by default.
refRef<HTMLButtonElement>—Receives the button or trigger; no ref by default.
styleCSSProperties—Inline styles on the documented visual root; no inline overrides by default.

Built from

Used in

Dependencies

lucide-react, motion

Import

import { HoldToConfirm } from "@beamline/hold-to-confirm";

Get it

Hold to confirm is part of Beamline UI. Install the parts you need in your React app as compiled packages or editable source. Hold to confirm 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…
  • 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.
  • Button: 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…

Guides: Build a SaaS settings page in React

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.