Skip to main content
Clever Ops

Confirm Hold Button

Press-and-hold confirmation for destructive actions, a radial destructive fill charges while held and fires only past the threshold; releasing early cancels. Holding Space counts exactly the same.

Preview & code

Loading Confirm Hold Button preview

Installation

pnpm dlx shadcn@latest add @cleverui/button-confirm-hold

Requires the @cleverui registry in your components.json, a one-off, two-line setup.

Usage

tsx
import { ButtonConfirmHold } from '@/components/ui/button-confirm-hold'
Exampletsx
'use client'

import { useState } from 'react'
import { ButtonConfirmHold } from '@/components/ui/button-confirm-hold'

export default function ButtonConfirmHoldDemo() {
  const [deleted, setDeleted] = useState(false)
  const [revoked, setRevoked] = useState(false)

  return (
    <div className="mx-auto flex min-h-[380px] max-w-lg flex-col items-center justify-center gap-10 px-6 py-16">
      <div className="w-full max-w-sm space-y-3 text-center">
        <p className="font-mono text-[11px] uppercase tracking-[0.2em] text-muted-foreground">
          Workspace · Northwind Analytics
        </p>
        <p className="text-sm leading-relaxed text-muted-foreground">
          {deleted
            ? 'Workspace queued for permanent deletion. Billing stops at cycle end.'
            : 'This removes all dashboards, API keys, and audit history for the workspace.'}
        </p>
        <div className="flex justify-center pt-2">
          {deleted ? (
            <span className="inline-flex h-11 items-center rounded-lg border border-border/60 px-5 text-sm font-medium text-muted-foreground">
              Deletion scheduled
            </span>
          ) : (
            <ButtonConfirmHold onConfirm={() => setDeleted(true)}>
              Delete workspace
            </ButtonConfirmHold>
          )}
        </div>
      </div>

      <div className="w-full max-w-sm space-y-3 border-t border-border/60 pt-10 text-center">
        <p className="font-mono text-[11px] uppercase tracking-[0.2em] text-muted-foreground">
          Session · deploy token
        </p>
        <div className="flex justify-center pt-1">
          {revoked ? (
            <span className="inline-flex h-11 items-center rounded-lg border border-border/60 px-5 text-sm font-medium text-muted-foreground">
              Token revoked
            </span>
          ) : (
            <ButtonConfirmHold
              holdMs={1000}
              hint="Hold to revoke"
              onConfirm={() => setRevoked(true)}
            >
              Revoke deploy token
            </ButtonConfirmHold>
          )}
        </div>
      </div>
    </div>
  )
}

API reference

ButtonConfirmHold accepts the following props.

PropTypeDefaultDescription
children*React.ReactNodeaction label, e.g. 'Delete workspace'
onConfirm*() => voidfires exactly once when a hold crosses the threshold
holdMsnumber800hold duration required to confirm, in ms
iconLucideIconTrash2leading icon; defaults to Trash2
hintstring'Hold to confirm'mono micro-caption shown after a plain tap

…plus everything from Omit< React.ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'onClick' | 'onDrag' | 'onDragStart' | 'onDragEnd' | 'onAnimationStart' >: className, event handlers, aria attributes and the rest pass straight through.

Frequently asked questions

How do I install the Confirm Hold Button component?

Register the @cleverui registry in your components.json ("@cleverui": "https://cleverops.com.au/r/{name}.json"), then run `npx shadcn@latest add @cleverui/button-confirm-hold`. The shadcn CLI copies the source into your project, you own the code from that point. You can also copy the source directly from this page.

What dependencies does Confirm Hold Button require?

Confirm Hold Button uses motion and lucide-react on top of React and Tailwind CSS. You don't need to install them manually, the shadcn CLI resolves and installs npm dependencies automatically when you add the component.

Can I theme Confirm Hold Button to match my brand?

Yes. The component is styled entirely with Tailwind utilities over standard design tokens (primary, background, muted, border), so it inherits your existing shadcn/ui theme automatically. Change your CSS variables and the component follows, no source edits needed for palette, radius, or fonts.

Want this built for you?

CleverUI is built by the Clever Ops web team. If you'd rather ship a hand-coded, fast, custom website than assemble one, we build them for Australian businesses every week.

Explore web development services