Alert Dialog
A modal dialog that interrupts the user with important content and expects a response.
import {
AlertDialog,
AlertDialogAction,
AlertDialogBody,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogIcon,
AlertDialogTitle,
AlertDialogTrigger,
} from "@ngrok/mantle/alert-dialog";
import { Button } from "@ngrok/mantle/button";
<AlertDialog priority="info">
<AlertDialogTrigger asChild>
<Button type="button" appearance="outlined">
Show Info Alert Dialog
</Button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogIcon />
<AlertDialogBody>
<AlertDialogHeader>
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
<AlertDialogDescription>
Proident quis nisi tempor irure sunt ut minim occaecat mollit sunt.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel type="button">Cancel</AlertDialogCancel>
<AlertDialogAction type="button">Continue</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogBody>
</AlertDialogContent>
</AlertDialog>
<AlertDialog priority="danger">
<AlertDialogTrigger asChild>
<Button type="button" appearance="outlined">
With a form
</Button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogIcon />
<AlertDialogBody>
<AlertDialogHeader>
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
<AlertDialogDescription>
Proident quis nisi tempor irure sunt ut minim occaecat mollit sunt.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel type="button">Cancel</AlertDialogCancel>
<form
onSubmit={(event) => {
event.preventDefault();
window.alert("Form submitted!");
}}
>
<AlertDialogAction type="submit">Continue</AlertDialogAction>
</form>
</AlertDialogFooter>
</AlertDialogBody>
</AlertDialogContent>
</AlertDialog>
API Reference
The AlertDialog
components are built on top of Radix Alert Dialog.
AlertDialog
The root component for the Alert Dialog.
All props from Radix Dialog.Root, plus:
AlertDialogTrigger
A button that opens the Alert Dialog.
Radix Dialog.Trigger props.
AlertDialogContent
The popover Alert Dialog container. Renders on top of the overlay and is centered in the viewport.
Radix Dialog.Content props, plus:
AlertDialogBody
Contains the main content of the alert dialog.
The AlertDialogBody
accepts the following props in addition to the standard HTML div attributes.
AlertDialogHeader
Contains the header content of the dialog, including the title and description.
The AlertDialogHeader
accepts the following props in addition to the standard HTML div attributes.
AlertDialogFooter
Contains the footer content of the dialog, including the action and cancel buttons.
The AlertDialogFooter
accepts the following props in addition to the standard HTML div attributes.
AlertDialogTitle
An accessible name to be announced when the dialog is opened.
Alternatively, you can provide aria-label
or aria-labelledby
to AlertDialogContent
and exclude this component.
Radix Dialog.Title props.
AlertDialogDescription
An accessible description to be announced when the dialog is opened.
Alternatively, you can provide aria-describedby
to AlertDialogContent
and exclude this component.
Radix Dialog.Description props.
AlertDialogAction
A button that confirms the Alert Dialog action. Will default to appearance="filled"
, as well as the priority color from the AlertDialog
. Does not close the alert dialog by default.
These buttons should be distinguished visually from the AlertDialogCancel
button.
Composes around the mantle Button component.
Same props as the Button component.
AlertDialogCancel
A button that closes the dialog and cancels the action. Will default to appearance="outlined"
and priority="neutral"
.
This button should be distinguished visually from AlertDialogAction
buttons.
Composes around the mantle Button component.
Same props as the Button component.