Skip to content

components/bits/ConfirmDialog#

ConfirmDialog()#

function ConfirmDialog(props): Element;

Generic confirmation dialog for destructive or irreversible actions.

Supports an icon, a busy state and translated copy.

Renders through StyledDialog so it matches the app's dialog style.

Parameters#

Parameter Type
props ConfirmDialogProps

Returns#

Element


ConfirmDialogProps#

Properties#

busy?#

optional busy?: boolean;

Keeps the dialog open with a spinner while the action is in flight.

cancelLabel?#

optional cancelLabel?: string;

Defaults to the shared common:buttons.cancel label.

children?#

optional children?: ReactNode;

Extra content between the message and the actions (a checkbox, a list).

confirmDisabled?#

optional confirmDisabled?: boolean;

Disables the confirm action.

confirmErrorMessage?#

optional confirmErrorMessage?: string;

Shown if onConfirm throws. Defaults to a generic "Something went wrong".

confirmLabel#

confirmLabel: string;

confirmTooltip?#

optional confirmTooltip?: string;

Shown on the confirm action, e.g. why it is disabled.

destructive?#

optional destructive?: boolean;

Renders the confirm action in error colors and tints the icon tile.

extraAction?#

optional extraAction?: {
  label: string;
  onClick: () => void;
};

A third choice between Cancel and the confirm action (a milder alternative to it).

label#
label: string;
onClick#
onClick: () => void;
Returns#

void

icon?#

optional icon?: ElementType<any, keyof IntrinsicElements> | null;

Pass null to drop the icon tile entirely.

maxWidth?#

optional maxWidth?: "xs" | "sm";

xs (the default) for a one-line question, sm when the copy is longer.

message#

message: ReactNode;

onClose#

onClose: () => void;
Returns#

void

onConfirm#

onConfirm: () => unknown;

Runs on confirm. Return a promise to keep the dialog open, disabled, and (after the progress delay) spinning until it settles; a second confirm meanwhile is dropped.

Returns#

unknown

open#

open: boolean;

sx?#

optional sx?: any;

Forwarded to the underlying dialog — layering, mostly.

title#

title: string;