Skip to content

Dialog

Dialog Primitive

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 dialog

Usage

import * as React from 'react';
import { Button } from '~/components/ui/button';
import {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from '~/components/ui/dialog';
import { Text } from '~/components/ui/text';
function Example() {
return (
<Dialog>
<DialogTrigger asChild>
<Button variant='outline'>
<Text>Edit Profile</Text>
</Button>
</DialogTrigger>
<DialogContent className='sm:max-w-[425px]'>
<DialogHeader>
<DialogTitle>Edit profile</DialogTitle>
<DialogDescription>
Make changes to your profile here. Click save when you're done.
</DialogDescription>
</DialogHeader>
<DialogFooter>
<DialogClose asChild>
<Button>
<Text>OK</Text>
</Button>
</DialogClose>
</DialogFooter>
</DialogContent>
</Dialog>
);
}

Props

Dialog

Extends View props

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

DialogTrigger

Extends Pressable props

PropTypeNote
asChildboolean(optional)

DialogOverlay

Extends View props

PropTypeNote
asChildboolean(optional)
forceMounttrue | undefined;(optional)
closeOnPressboolean(optional)

DialogPortal

PropTypeNote
children*React.ReactNode
forceMounttrue | undefined(optional)
hostNamestringWeb Only (optional)
containerHTMLElement | null | undefinedWeb Only (optional)

DialogContent

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)
onInteractOutside(ev: Event) => voidWeb Only (optional)
onPointerDownOutside(ev: Event) => voidWeb Only (optional)

DialogHeader

Extends View props

DialogTitle

Extends Text props

PropTypeNote
asChildboolean(optional)

DialogDescription

Extends Text props

PropTypeNote
asChildboolean(optional)

DialogFooter

Extends View props

DialogClose

Extends Pressable props

PropTypeNote
asChildboolean(optional)