Skip to content
Knsept
Free playbook

Hold-to-confirm button

A safer button for destructive actions. Press and hold until the bar fills; let go early to cancel.

JavaScriptUI Widgets Updated Oct 23, 2026
Live demo Reduced motion is on, so effects are toned down
<button class="hold" type="button" aria-describedby="hold-help">
  <span class="hold-fill" aria-hidden="true"></span>
  <span class="hold-label">Hold to delete</span>
</button>
<p id="hold-help" class="hold-help">Press and hold (or hold Space/Enter) for one second.</p>

Destructive actions are easy to trigger by accident. A one-second hold is a lighter alternative to an "Are you sure?" dialog: it's quick when you mean it and nearly impossible to do by mistake.

Progress is driven by requestAnimationFrame and measured against performance.now(), so it's accurate even if a frame is dropped. The bar is a transform: scaleX(), which animates smoothly without layout work.

Touch: touch-action: none, -webkit-touch-callout: none and a blocked contextmenu stop the phone from scrolling, zooming or opening a long-press menu while you hold. Keyboard: hold Space or Enter; releasing the key cancels, just like lifting a finger.

More from the library

Buttons live

Ripple button

A bright press ripple that starts exactly where you click or tap, and from the center for keyboard users.

Buttons live

Glowing gradient border

A button with a rotating gradient border and soft glow, done with one registered CSS property and no extra elements.

Buttons live

Magnetic button

A button that leans toward the cursor and springs back. Press-and-drag on touch, gentler with reduced motion.