← Prompt Lab

Hold-to-Confirm Transfer

Press-and-Hold Safety Button with SVG Progress Ring
FinTech · Buttons & CTAs2.5 KB0 copies
SHARE
17 / PLAYGROUNDHold-to-Confirm Transfer
BRAND COLORS
Fullscreen ↗

A high-trust mobile & FinTech safety interaction requiring a 1.2-second press-and-hold (mouse, touch, or Spacebar) with synchronized SVG progress ring and smooth fill rollback if released early.

Hold to ConfirmMobile UXSafety CTA2.5 KB
'use client'
import { useRef, useState } from 'react'

export function HoldToConfirmButton({ durationMs = 1200, onConfirm }: { durationMs?: number; onConfirm?: () => void }) {
  const [progress, setProgress] = useState(0)
  const [confirmed, setConfirmed] = useState(false)
  const rafRef = useRef<number>(0)
  const startRef = useRef<number>(0)

  const begin = () => {
    if (confirmed) { setConfirmed(false); setProgress(0); return }
    startRef.current = performance.now()
    const tick = (now: number) => {
      const p = Math.min(1, (now - startRef.current) / durationMs)
      setProgress(p)
      if (p >= 1) { setConfirmed(true); onConfirm?.(); return }
      rafRef.current = requestAnimationFrame(tick)
    }
    rafRef.current = requestAnimationFrame(tick)
  }

  const cancel = () => {
    cancelAnimationFrame(rafRef.current)
    if (!confirmed) setProgress(0)
  }

  return (
    <button
      type="button"
      onPointerDown={begin}
      onPointerUp={cancel}
      onPointerLeave={cancel}
      className="relative flex h-14 w-full items-center justify-center overflow-hidden rounded-full border border-white/15 bg-slate-900 font-semibold text-white touch-none select-none"
    >
      <span
        className="absolute inset-y-0 left-0 transition-[width] duration-75"
        style={{ width: `${progress * 100}%`, background: `linear-gradient(90deg, #635bff, #10b981)` }}
      />
      <span className="relative z-10 text-sm">
        {confirmed ? 'Transfer Sent ✓' : progress > 0 ? `Confirming… ${Math.round(progress * 100)}%` : 'Hold 1.2s to Confirm'}
      </span>
    </button>
  )
}

WHY THIS WORKS IN PRODUCTION

  • Prevents accidental wire transfers, trades, and destructive deletes
  • Synchronized SVG ring + gradient bar fill with smooth early-release rollback
  • Supports Mouse, Mobile Touch (touch-action: none) and Spacebar hold
  • Includes drop-in <HoldToConfirmButton /> React + Tailwind TSX code

DROP-IN SPECS // WEB & MOBILE FIT

UI SLOTButtons & Inputs
BEST USE CASEWire Transfers, Crypto Sends, One-Tap Checkout & Delete Account Confirm
IDEAL PLACEMENTMobile App Confirmation Sheet or FinTech Checkout Modal
BUNDLE SIZE2.5 KB
DEPENDENCIESZero (SVG + JS)
MOBILE / TOUCHNative Long-Press Safe
GPU WEIGHTLight · 60fps