Skip to content

AlertDialog

A modal confirmation dialog for destructive or irreversible actions.

Delete item?

This action cannot be undone.

<>
<Button label="Delete item" onClick={() => setIsOpen(true)} />
<AlertDialog
actionLabel="Delete"
description="This action cannot be undone."
isOpen={isOpen}
onAction={() => setIsOpen(false)}
onOpenChange={setIsOpen}
title="Delete item?"
/>
</>

Delete item?

This action cannot be undone.

<>
<Button label="Delete item" onClick={() => setIsOpen(true)} />
<AlertDialog
actionLabel="Delete"
description="This action cannot be undone."
isActionLoading
isOpen={isOpen}
onAction={() => setIsOpen(false)}
onOpenChange={setIsOpen}
title="Delete item?"
/>
</>

Delete item?

This action cannot be undone.

<>
<Button label="Delete item" onClick={() => setIsOpen(true)} />
<AlertDialog
actionLabel="Delete"
cancelLabel="No, keep it"
description="This action cannot be undone."
isOpen={isOpen}
onAction={() => setIsOpen(false)}
onOpenChange={setIsOpen}
title="Delete item?"
/>
</>

Archive project?

Archived projects can be restored later.

<>
<Button label="Archive project" onClick={() => setIsOpen(true)} />
<AlertDialog
actionLabel="Archive"
actionVariant="primary"
description="Archived projects can be restored later."
isOpen={isOpen}
onAction={() => setIsOpen(false)}
onOpenChange={setIsOpen}
title="Archive project?"
/>
</>

Wide dialog

This dialog uses a custom width of 600px.

<>
<Button label="Open wide dialog" onClick={() => setIsOpen(true)} />
<AlertDialog
actionLabel="Confirm"
description="This dialog uses a custom width of 600px."
isOpen={isOpen}
onAction={() => setIsOpen(false)}
onOpenChange={setIsOpen}
title="Wide dialog"
width={600}
/>
</>

Are you sure you want to permanently delete this project and all of its contents?

This action will permanently delete all associated data, including files, comments, activity history, and any linked resources. Once deleted, this information cannot be recovered. Please make sure you have backed up anything you need before proceeding.

<>
<Button label="Delete project" onClick={() => setIsOpen(true)} />
<AlertDialog
actionLabel="Delete"
description="This action will permanently delete all associated data, including files, comments, activity history, and any linked resources. Once deleted, this information cannot be recovered. Please make sure you have backed up anything you need before proceeding."
isOpen={isOpen}
onAction={() => setIsOpen(false)}
onOpenChange={setIsOpen}
title="Are you sure you want to permanently delete this project and all of its contents?"
/>
</>
<>
<Button
label="Open imperative alert"
onClick={() =>
alert.show({
actionLabel: 'Archive',
actionVariant: 'primary',
description: 'Archived projects can be restored later.',
onAction: alert.hide,
title: 'Archive project?',
})
}
/>
{alert.element}
</>

A modal confirmation dialog for destructive or irreversible actions.

PropTypeDefaultDescription
actionLabel*stringAction button label.
actionVariant"destructive" | "primary"'destructive'Visual variant for the action button.
cancelLabelstring'Cancel'Cancel button label.
classNamestringAdditional CSS class names applied to the dialog.
data-testidstringTest ID applied to the dialog.
description*stringConsequence description.
isActionLoadingbooleanfalseWhether the action button is loading.
isOpen*booleanWhether the dialog is open.
onAction*() => voidCalled when the primary action is clicked.
onOpenChange*(isOpen: boolean) => voidCalled when the dialog requests an open-state change.
refRef<HTMLDialogElement>Ref forwarded to the dialog element.
styleCSSPropertiesInline styles applied to the dialog.
title*stringDialog title.
widthnumber | string400Dialog width. Numbers are treated as pixels.