ConfirmDialog
neon-ui/confirm-dialogFreeComponent
Destructive confirmation modal armed by press-and-hold, with keyboard hold support.
Install it
npx shadcn@latest add https://ui.neon.com/r/confirm-dialog.jsonSource
1"use client";23import type { CSSProperties, KeyboardEvent, ReactNode } from "react";4import { useEffect, useRef, useState } from "react";56import { Button } from "@/components/ui/button";7import {8 Dialog,9 DialogContent,10 DialogDescription,11 DialogFooter,12 DialogHeader,13 DialogTitle,14} from "@/components/ui/dialog";15import { cn } from "@/lib/utils";1617export interface ConfirmDialogProps {18 open: boolean;19 onOpenChange: (open: boolean) => void;20 /** Runs after the hold completes; the dialog closes itself. */21 onConfirm: () => void;22 /** One line naming the action, e.g. "Restore this checkpoint?". */23 title: string;24 /** What happens and what it costs — say it plainly. */25 description?: ReactNode;26 /** Label inside the hold action. */27 confirmLabel?: string;28 cancelLabel?: string;29 /** How long the hold takes to arm, in milliseconds. */30 holdMs?: number;31 /**32 * The hold trembles as it approaches commitment — barely a shiver33 * at the start, unmistakable by the end. Off under reduced motion.34 */35 shake?: boolean;36}3738/* ─────────────────────────────────────────────────────────39 * HOLD-TO-CONFIRM STORYBOARD40 *41 * A destructive action shouldn't be one twitch away. The42 * dialog asks; the hold answers.43 *44 * open overlay fades, the panel rises 8px45 * rest the action wears destructive as a border and46 * text — armed, not fired47 * hold press and hold: a destructive fill sweeps48 * left to right for exactly holdMs (linear —49 * progress, not easing). The fill carries its50 * own destructive-foreground copy of the label,51 * revealed by the same clip-path, so the sweep52 * edge crosses the letterforms — white behind53 * it, destructive ahead of it, never a flip.54 * With shake on, the button trembles harder as55 * the fill closes in — amplitude eases from 056 * to 2.5px over the hold (ease-in: dread builds57 * late), mixing axes so it reads as strain58 * release let go early and the fill springs back59 * (180ms ease-out) — no harm done60 * arm the fill lands, onConfirm fires once, the61 * dialog closes62 * keyboard holding Space or Enter works the same way;63 * key repeat is ignored64 *65 * The clip-path label split was suggested by Gurbinder66// … truncated
What it pulls in
Other registry items
Files it writes
More from neon-ui
All 77 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| ActivityFeedactivity-feed | neon-ui | Components | Free | 2 deps | |
| AgentChatagent-chat | neon-ui | Components | Free | 6 deps | |
| AnimatedWashanimated-wash | neon-ui | Components | Free | no deps · 2 files | |
| ApiKeyListapi-key-list | neon-ui | Components | Free | 2 deps | |
| AppCardapp-card | neon-ui | Components | Free | 2 deps | |
| AppCreatorapp-creator | neon-ui | Components | Free | 2 deps | |
| AuthFormauth-form | neon-ui | Components | Free | no deps | |
| AutoscaleChartautoscale-chart | neon-ui | Components | Free | 1 dep |
