Component

A dialog that is used to display a message to the user. It is used to confirm or cancel an action.

View component changelog
preview
React
"use client" import AlertDialog from "@radui/ui/AlertDialog"; const AlertDialogExample = () => { return ( <div className="w-64 md:w-96 flex justify-center items-center"> <AlertDialog.Root> <AlertDialog.Trigger> Open Dialog </AlertDialog.Trigger> <AlertDialog.Portal> <AlertDialog.Overlay /> <AlertDialog.Content> <AlertDialog.Title> Are you sure you want to delete this file? </AlertDialog.Title> <AlertDialog.Description> This action cannot be undone. </AlertDialog.Description> <AlertDialog.Footer> <AlertDialog.Cancel> Cancel </AlertDialog.Cancel> <AlertDialog.Action> Delete </AlertDialog.Action> </AlertDialog.Footer> </AlertDialog.Content> </AlertDialog.Portal> </AlertDialog.Root> </div>) } export default AlertDialogExample;

Import all parts of the component and piece them together

React
import AlertDialog from "@radui/ui/AlertDialog"; export default () => { return ( <AlertDialog.Root> <AlertDialog.Trigger>Open alert</AlertDialog.Trigger> <AlertDialog.Portal> <AlertDialog.Overlay/> <AlertDialog.Content> <AlertDialog.Title>Alert dialog title</AlertDialog.Title> <AlertDialog.Description>Alert dialog description</AlertDialog.Description> <AlertDialog.Footer> <AlertDialog.Cancel>Cancel</AlertDialog.Cancel> <AlertDialog.Action>Confirm</AlertDialog.Action> </AlertDialog.Footer> </AlertDialog.Content> </AlertDialog.Portal> </AlertDialog.Root> ) }

The root component for the AlertDialog.

PropTypeDefault
className
string
--
customRootClass
string
--
open
boolean
--
defaultOpen
boolean
false
onOpenChange
function
--
dismissOnOutsidePress
boolean
false

The trigger component for the AlertDialog.

PropTypeDefault
className
string
--
asChild
boolean
false

The portal component for the AlertDialog.

PropTypeDefault
children
ReactNode
--
container
Element | null
--
forceMount
boolean
false
keepMounted
boolean
false

The overlay component for the AlertDialog.

PropTypeDefault
className
string
''
asChild
boolean
false
forceMount
boolean
false

The content component for the AlertDialog.

PropTypeDefault
className
string
''
children
ReactNode
--
asChild
boolean
false
forceMount
boolean
false

The title component for the AlertDialog.

PropTypeDefault
className
string
''
children
ReactNode
--
asChild
boolean
false
id
string
auto

The description component for the AlertDialog.

PropTypeDefault
className
string
''
children
ReactNode
--
asChild
boolean
false
id
string
auto

A layout container for alert dialog actions.

PropTypeDefault
className
string
''

The action component for the AlertDialog.

PropTypeDefault
className
children
ReactNode
--
asChild
boolean
false

The cancel component for the AlertDialog.

PropTypeDefault
className
children
ReactNode
--
asChild
boolean
false
ShortcutDescription
Escape

Closes the alert dialog when cancel or dismiss behavior is available.

Tab

Moves focus to the next focusable control inside the alert dialog.

Shift + Tab

Moves focus to the previous focusable control inside the alert dialog.

ReferenceWhat Rad UI follows

Uses alert dialog semantics for confirmation flows that interrupt the current task and require a response.

Inherits modal dialog focus containment, labelling, description, and focus restoration expectations.