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-dialog
Copy/paste the following code for web to ~/components/primitives/dialog/dialog.web.tsx
Copy/paste the following code for native to ~/components/primitives/dialog/dialog.tsx
Copy/paste the following code for types to ~/components/primitives/dialog/types.ts
Copy/paste the following code for exporting to ~/components/primitives/dialog/index.ts
Copy/paste the following code for native to ~/components/primitives/dialog/index.tsx
Copy/paste the following code for types to ~/components/primitives/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 Pressable
props
Prop | Type | Note |
---|---|---|
asChild | boolean | (optional) |
forceMount | true | undefined; | (optional) |
closeOnPress | boolean | (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) |
onInteractOutside | (ev: Event) => void | Web Only (optional) |
onPointerDownOutside | (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) |
Close
Extends Pressable
props
Prop | Type | Note |
---|---|---|
asChild | boolean | (optional) |
useRootContext
Must be used within a Root
component. It provides the following values from the dialog: open
, and onOpenChange
.