Swipe actions
Reveal row actions with a swipe, or from the same actions in a menu.
Confirm a destructive action by holding, not tapping.
npx shadcn@latest add @silicon-ui/hold-to-confirmnpx shadcn@latest add @silicon-ui/hold-to-confirmInstall the dependencies.
npm install lucide-react motionCopy these files into your project. Shared files are skipped if you already have them.
components/silicon-ui/hold-to-confirm/hold-to-confirm.tsxcomponents/silicon-ui/hold-to-confirm/hold-to-confirm.module.cssInstall the foundation once per app for the design and motion tokens: npx shadcn@latest add @silicon-ui/silicon-foundation
| Prop | Type | Default |
|---|---|---|
label*The instruction and the action, for example “Hold to delete project”. | string | — |
onConfirm*Called once when the hold completes. | () => void | — |
confirmedLabelShown once the hold completes, for example “Deleted”. | string | "Done" |
durationHold length in milliseconds. | number | 1200 |
icon | ReactNode | <Trash2 strokeWidth={1.75} /> |
tone`accent` (default) fills with the selected accent; `danger` is for an irreversible action; `neutral` fills with the foreground. | "accent" | "danger" | "neutral" | "accent" |
confirmedControls the done state. Set it back to false to reset the button; leave it undefined to let the button keep its own state. | boolean | — |
onHoldChangeReports when a hold starts and ends, for surrounding hints such as “Keep holding”. | (holding: boolean) => void | — |
Also accepts the props of ButtonHTMLAttributes<HTMLButtonElement>, except children, onClick, onDrag, onDragEnd, onDragStart, onAnimationStart, onAnimationEnd.