Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Hold Button

ProNew

Press and hold to confirm. The fill inverts the label as it sweeps, and rewinds if you let go.

Installation

pnpm dlx shadcn@latest add @viewport/hold-button

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above comes with Truffle Pro.

Props

PropTypeDefault
onConfirm*() => void

Called once the button has been held for the full duration.

—
durationnumber

Milliseconds the button must be held.

1400
confirmedTextstring

Label shown briefly after confirming.

"Done"
fillClassNamestring

Classes for the fill that sweeps across, e.g. `bg-emerald-600 text-white`.

—

Accessibility

  • Works by holding Space or Enter as well as a pointer.
  • A click from assistive technology, which cannot hold, confirms directly.
  • The result is announced through a live region.