useConfirm
useConfirm():
ConfirmFn
Defined in: packages/ui/src/hooks/use-confirm.ts:47
Returns an imperative ConfirmFn that opens a confirmation dialog
and resolves to true (confirmed) or false (cancelled/dismissed).
Must be used within a ConfirmProvider — typically supplied by the
Joy UI plugin or a custom UI plugin implementation.
Returns
Section titled “Returns”ConfirmFn
A ConfirmFn that accepts ConfirmOptions and returns a Promise<boolean>.
Throws
Section titled “Throws”If called outside of a ConfirmProvider.
Example
Section titled “Example”function DangerZone() { const confirm = useConfirm();
async function handleDelete() { const ok = await confirm({ title: "Delete account", description: "This action cannot be undone.", confirmLabel: "Delete", variant: "danger", }); if (ok) { /* proceed */ } }
return <button onClick={handleDelete}>Delete</button>;}