Skip to main content
v7

HoldToConfirm

A button that runs its action only after being held down, for destructive actions whose consequence is already visible on screen.

Package@g4rcez/componentsSectionDisplay Components

Examples

Delete a branch

The fill advances while held and rewinds on release. Completion calls onConfirm once, swaps the label and draws a check. Pass confirmed to reset the button after an undo or a failed request.

Danger tone
Press and hold for 1.2 seconds to confirm. With the keyboard, hold Space or Enter.

Nothing deleted yet.

Neutral tone and custom duration

duration sets the hold in milliseconds, tone switches the fill to a neutral color and icon replaces the leading trash icon. onHoldChange reports when a hold starts and ends.

Two second hold
Press and hold for 2 seconds to confirm. With the keyboard, hold Space or Enter.

Hold the button for two seconds.

When to use HoldToConfirm

Use when

Use HoldToConfirm for destructive or hard-to-undo actions, like deleting a branch or force pushing, where the person can already see what will happen.

Avoid when

Avoid it for safe, easily reversed actions, where a Button is enough, and when people need to read the consequences first, where a Modal fits better.

Accessibility

Press and hold with a mouse, finger or pen, or hold Space or Enter. Releasing early, tabbing away or sliding well off the button cancels. A hidden hint describes the hold, the label follows the visible text and a polite status announces the result.