Alert Dialog Primitive
A modal dialog that interrupts the user with important content and expects a response.
Installation
Install the component via your command line.
Install @radix-ui/react-alert-dialog
Copy/paste the following code for web to ~/components/primitives/alert-dialog/alert-dialog.web.tsx
Copy/paste the following code for native to ~/components/primitives/alert-dialog/alert-dialog.tsx
Copy/paste the following code for types to ~/components/primitives/alert-dialog/types.ts
Copy/paste the following code for exporting to ~/components/primitives/alert-dialog/index.ts
Copy/paste the following code for native to ~/components/primitives/alert-dialog/index.tsx
Copy/paste the following code for types to ~/components/primitives/alert-dialog/types.ts
Usage
Props
Root
Extends View
props
Prop | Type | Note |
---|---|---|
asChild | boolean | (optional) |
open | boolean | (optional) |
onOpenChange | (value: boolean) => void | (optional) |
defaultOpen | boolean | (optional) |
Trigger
Extends Pressable
props
Prop | Type | Note |
---|---|---|
asChild | boolean | (optional) |
Overlay
Extends View
props
Prop | Type | Note |
---|---|---|
asChild | boolean | (optional) |
forceMount | true | undefined; | (optional) |
Portal
Prop | Type | Note |
---|---|---|
children* | React.ReactNode | |
forceMount | true | undefined | (optional) |
hostName | string | Web Only (optional) |
container | HTMLElement | null | undefined | Web Only (optional) |
Content
Extends View
props
Prop | Type | Note |
---|---|---|
asChild | boolean | (optional) |
forceMount | true | undefined | (optional) |
alignOffset | number | Native Only (optional) |
insets | Insets | Native Only (optional) |
avoidCollisions | boolean | Native Only (optional) |
align | ’start’ | ‘center’ | ‘end’ | Native Only (optional) |
side | ’top’ | ‘bottom’ | Native Only (optional) |
sideOffset | number | Native Only (optional) |
disablePositioningStyle | boolean | Native Only (optional) |
onOpenAutoFocus | (ev: Event) => void | Web Only (optional) |
onCloseAutoFocus | (ev: Event) => void | Web Only (optional) |
onEscapeKeyDown | (ev: Event) => void | Web Only (optional) |
Title
Extends Text
props
Prop | Type | Note |
---|---|---|
asChild | boolean | (optional) |
Description
Extends Text
props
Prop | Type | Note |
---|---|---|
asChild | boolean | (optional) |
Cancel
Extends Pressable
props
Prop | Type | Note |
---|---|---|
asChild | boolean | (optional) |
Action
Extends Pressable
props
Prop | Type | Note |
---|---|---|
asChild | boolean | (optional) |
useRootContext
Must be used within a Root
component. It provides the following values from the alert-dialog: open
, and onOpenChange
.