Hold Button
ProNewPress 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
| Prop | Type | Default |
|---|---|---|
| onConfirm* | () => voidCalled once the button has been held for the full duration. | — |
| duration | numberMilliseconds the button must be held. | 1400 |
| confirmedText | stringLabel shown briefly after confirming. | "Done" |
| fillClassName | stringClasses 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.