Slide to confirm
FreeA deliberate commit: drag the handle to the end, or use the arrow keys, and it confirms; let go early and it springs back.
pnpm dlx shadcn@latest add https://caliperui.site/r/slide-to-confirm.jsonWhen to use #
Use it for
- Paying, sending to everyone, going live.
- Phone screens where a stray tap is costly.
Skip it when
- Everyday actions; a button is faster.
- Destructive actions that need an undo instead.
Installation #
pnpm dlx shadcn@latest add https://caliperui.site/r/slide-to-confirm.json
Adds its 2 files to components/ui/, each with its own stylesheet, and installs their packages. No account needed. The first part also adds Caliper UI’s tokens; import them once as in Installation.
Usage #
This is the code behind the preview above.
import { useState } from "react" import { SlideToConfirm } from "@/components/ui/slide-to-confirm" const wait = (ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms)); export function SlideToConfirmDemo() { const [round, setRound] = useState(0); return ( <div className="grid w-full max-w-sm gap-3"> <SlideToConfirm key={round} label="Slide to pay €1,240" confirmingLabel="Paying…" doneLabel="Paid €1,240" onConfirm={() => wait(1200)} /> <button type="button" className="w-fit text-sm text-muted-foreground underline underline-offset-4" onClick={() => setRound((n) => n + 1)}>Start again</button> </div> ); }
API reference #
SlideToConfirm
component
Accessibility #
It exposes slider and status semantics, with aria-disabled, aria-hidden, aria-label, aria-valuemin, aria-valuemax and aria-valuenow kept in step with state. Changes that matter are announced through a live region.
Motion #
It declares no animation in its component source. Any transition comes from its stylesheet, which uses the duration tokens that collapse to instant under prefers-reduced-motion.