Updated
Hold to Confirm
Customize
Sweep
Color
Medium
Duration1.2s
Reset after1.6s
Radius14px
Installation
npx shadcn@latest add https://uibrik.com/r/hold-to-confirm.jsonInstall the packages
npm install @tabler/icons-react motionAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/hold-to-confirm/hold-to-confirm.tsx"use client"; import { IconCheck, IconTrash } from "@tabler/icons-react"; import { animate, motion, useTransform, useMotionValue, type AnimationPlaybackControls } from "motion/react"; import { useEffect, useRef, useState, type ReactNode } from "react"; import { cn } from "@/lib/utils"; const EASE_OUT: [number, number, number, number] = [0.23, 1, 0.32, 1]; // Letting go early drains the fill quickly, so an aborted hold reads as // "nothing happened" rather than a second animation to watch. const RELEASE_DURATION = 0.35; const SIZES = { sm: { height: 32, padX: 12, font: 13, icon: 15 }, md: { height: 40, padX: 16, font: 14, icon: 17 }, lg: { height: 48, padX: 20, font: 15, icon: 19 }, } as const; /** * How the fill grows while held. * - sweep: left to right, like a progress bar * - rise: bottom to top, like filling a glass * - center: out from the middle to both edges
Adds the files to
components/uibrik/hold-to-confirm and installs @tabler/icons-react and motion. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/hold-to-confirm.Usage
import { HoldToConfirm } from "@/components/uibrik/hold-to-confirm/hold-to-confirm";<HoldToConfirm label="Hold to delete" doneLabel="Deleted" fill="sweep" color="#dc2626" size="md" icon duration={1.2} resetAfter={1.6} radius={14} onConfirm={() => {}}/>Where to use Hold to Confirm
Deleting accounts and data
Holding the button down makes a destructive action deliberate without a second dialog.
Pairs with Inline Confirm
Admin danger zones
A fill that drains back if released early prevents accidental resets and wipes.
Pairs with Settings Page
Payments and transfers
A held confirmation suits money movement where a slip of the finger is costly.
Pairs with Amount Pad
Props
HoldToConfirm- label
- Type string
- "Hold to delete"
- Shown while waiting for a hold.
- doneLabel
- Type string
- "Deleted"
- Shown once the hold completes.
- fill
- Type "sweep" | "rise" | "center"
- "sweep"
- How the fill grows while held: left to right, bottom to top, or out from the middle.
- color
- Type string
- "#dc2626"
- Colour of the fill.
- size
- Type "sm" | "md" | "lg"
- "md"
- Height, padding and text size.
- icon
- Type boolean
- true
- Show the trash and check icons beside the labels.
- duration
- Type number
- 1.2
- How long the button must be held.
- resetAfter
- Type number
- 1.6
- How long the done state shows before re-arming.
- radius
- Type number
- 14
- Corner radius.
- onConfirm
- Type () => void
- –
- Called once the hold completes.
- className
- Type string
- –
- Classes for the button.