A `Modal` pre-wired with a message and confirm/cancel actions, for "are you sure?" moments such as confirming a delete.
A Modal pre-wired with a message and confirm/cancel actions, for "are you sure?" moments such as confirming a delete.
Usage
1import { ConfirmDialog } from "@behivetech/molecules.confirm-dialog";23<ConfirmDialog>Content</ConfirmDialog>;
Examples
Open all 1 →Basic Confirm Dialog
1const BasicConfirmDialog = () => {2 const [open, setOpen] = useState(false);34 return (5 <>6 <button type="button" onClick={() => setOpen(true)}>7 Delete page8 </button>9 <ConfirmDialog10 open={open}11 onOpenChange={setOpen}12 title="Delete page"13 message='Are you sure you want to delete "About Us"? This cannot be undone.'14 confirmLabel="Delete"15 variant="danger"16 onConfirm={() => console.log("confirmed delete")}17 />18 </>19 );20};2122render(<BasicConfirmDialog />);
Properties
ConfirmDialog props
| Prop | Type | Default | Description |
|---|---|---|---|
message* | ReactNode | — | Confirmation message/body content |
onConfirm* | () => void | — | Called when the confirm button is clicked, before the dialog closes |
onOpenChange* | (open: boolean) => void | — | Called when the dialog should close (cancel, confirm, backdrop click, Escape) |
open* | boolean | — | Whether the dialog is open |
title* | string | — | Dialog title |
cancelLabel | string | Cancel | Cancel button label; defaults to "Cancel" |
confirmLabel | string | Confirm | Confirm button label; defaults to "Confirm" |
variant | "default" | "danger" | default | Renders the confirm button as a destructive action; defaults to "default" |