Skip to content
Thrum

Hold to confirm

A button that acts only after it has been held down for a moment: delete, reset, revoke. It guards against a slip without opening a dialog. When the reader needs to know what will be lost before deciding, use a dialog instead: a hold confirms intent, it does not explain.

Install

npx shadcn@latest add @thrum-pro/hold-to-confirm

This is a Pro component. The command works once your project has a licence key: set up Pro or see pricing.

Props

PropTypeDefaultDescription
durationnumberDefault 1200How long the button must be held, in milliseconds.
onConfirm() => void–Called once per hold, when the time is up. Releasing early never calls it.
variant"default" | "destructive"Default "default"destructive draws the frame and the fill in the destructive colour, for an action that cannot be undone.
size"sm" | "md" | "lg"Default "md"sm is 28 pixels tall, md 32, lg 40.
hintstringDefault "Press and hold for 1.2 seconds to confirm."The sentence a screen reader reads after the name. The default states the duration in seconds.
confirmedLabelstringDefault "Confirmed"What a screen reader hears when the hold completes.
soundbooleanDefault truePlay a tick when the hold starts and two rising tones when it confirms, if the visitor has sound on.
disabledbooleanDefault falseThe native attribute: the button leaves the tab order and cannot be held.
childrenReactNode–The label. Say that it must be held: Hold to delete.
classNamestring–Extra classes, merged last.
...propsComponentProps<"button">–Every other button attribute and event handler is passed through. Your handlers run before the button's own.

Motion and sound

Motion

  • While the button is held, a fill grows across it from the start edge at constant speed and arrives when the time is up.
  • Letting go early runs the fill back to nothing in 150 ms. So does moving the pointer off the button, pressing Esc, or the button losing focus.
  • After a confirmed hold the fill stays full until the button is let go, then runs back.
  • The button scales to 97% while it is pressed.
  • Reduced motion: the fill does not move. The label is replaced by the time left, counting down in tenths of a second, and the fill appears whole when the hold is confirmed. The hold lasts just as long.

Sound

  • A tick when the hold starts.
  • Two rising tones when the hold is confirmed. An early release is silent.

Sound is off until the visitor turns it on. Pass sound={false} to keep this component silent. How sound works

Accessibility

  • It is a native button, named by its label. A hidden hint, linked with aria-describedby, says how long to hold.
  • A screen reader or a switch can often only click. A click with no pointer behind it starts the same countdown without holding, and a second click cancels it, so the action is never out of reach.
  • A polite live region says Confirmed when the hold completes.
  • The fill is a tint, and the label keeps its own colour over it. Progress never rests on the fill alone: the button's data-state goes from idle to holding to confirmed, and under reduced motion the time left is printed.
  • A hold is harder than a press for some people. Keep the duration short, and do not use it for an action people take often.
KeysAction
TabFocus the button.
Space / Enter (held)Start the hold. Keep the key down until the fill is complete; letting go earlier cancels.
EscCancel a hold in progress.

Source

SourcePro

The source comes with Pro

TypeScript source · Copy-paste ready · MIT-compatible for client projects · Includes all dependencies

Files and dependencies

Adds
components/ui/hold-to-confirm.tsx
Packages
motion
Brings along
ButtonMotion tokensSound engine

Changelog

  1. 1.0.0 · 2026-12-03First release.

Loading index…

Keyboard shortcuts

/Ctrl KSearch components, docs and actions
?Show this list
AAppearance studio
SSound on or off
MFull or reduced motion
TTheme: auto, light, dark
GSurface: solid or frosted
BBackdrop photograph (under glass)
CCorner radius: square to round
RReplay the demo, on a component page
DDraw new data, on a component page
←→HomeEndMove the cursor in a focused chart
EscClose a dialog, or leave a chart cursor