Skip to content

Alert Dialog

Alert Dialog Primitive Button Component Text Component

Demo


A modal dialog that interrupts the user with important content and expects a response.

Installation

Terminal window
npx @react-native-reusables/cli@latest add alert-dialog

Usage

import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from '~/components/ui/alert-dialog';
import { Button } from '~/components/ui/button';
import { Text } from '~/components/ui/text';
function AlertDialogScreen() {
return (
<AlertDialog>
<AlertDialogTrigger asChild>
<Button variant='outline'>
<Text>Show Alert Dialog</Text>
</Button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
<AlertDialogDescription>
This action cannot be undone. This will permanently delete your account and remove
your data from our servers.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>
<Text>Cancel</Text>
</AlertDialogCancel>
<AlertDialogAction>
<Text>Continue</Text>
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}

Props

AlertDialog

Extends View props

PropTypeNote
asChildboolean(optional)
openboolean(optional)
onOpenChange(value: boolean) => void(optional)
defaultOpenboolean(optional)

AlertDialogTrigger

Extends Pressable props

PropTypeNote
asChildboolean(optional)

AlertDialogContent

Extends View props

PropTypeNote
asChildboolean(optional)
forceMounttrue | undefined(optional)
alignOffsetnumberNative Only (optional)
insetsInsetsNative Only (optional)
avoidCollisionsbooleanNative Only (optional)
align’start’ | ‘center’ | ‘end’Native Only (optional)
side’top’ | ‘bottom’Native Only (optional)
sideOffsetnumberNative Only (optional)
disablePositioningStylebooleanNative Only (optional)
onOpenAutoFocus(ev: Event) => voidWeb Only (optional)
onCloseAutoFocus(ev: Event) => voidWeb Only (optional)
onEscapeKeyDown(ev: Event) => voidWeb Only (optional)

AlertDialogHeader

Extends View props

AlertDialogTitle

Extends Text props

PropTypeNote
asChildboolean(optional)

AlertDialogDescription

Extends Text props

PropTypeNote
asChildboolean(optional)

AlertDialogFooter

Extends View props

AlertDialogCancel

Extends Pressable props

PropTypeNote
asChildboolean(optional)

AlertDialogAction

Extends Pressable props

PropTypeNote
asChildboolean(optional)