A window overlaid on either the primary window or another dialog window, rendering the content underneath inert.
Loading...
Installation
Install the following dependencies:
Copy and paste the following code into your project.
Loading...
Update the import paths to match your project setup.
Composition
Dialog ├── DialogTrigger └── DialogContent ├── DialogHeader │ ├── DialogTitle │ └── DialogDescription ├── content ├── DialogFooter (optional) └── DialogClose
Examples
Default
Loading...
In A Form
Loading...
No Close Button
Loading...
Review Transfer
Loading...
Schedule Report
Loading...
Scrollable Content
Loading...
Settings
Loading...
Share Link
Loading...
Sticky Footer
Loading...
Upgrade Plan
Loading...
Welcome
Loading...
API Reference
Dialog
| Prop | Type | Default | Description |
|---|---|---|---|
id | string | undefined | — | Unique identifier used to connect the component parts. |
ids | ElementIds | undefined | — | Overrides generated identifiers for individual parts. |
trapFocus | boolean | undefined | — | Configures trap focus. |
preventScroll | boolean | undefined | — | Configures prevent scroll. |
modal | boolean | undefined | — | Configures modal. |
initialFocusEl | (() => MaybeElement) | undefined | — | Configures initial focus el. |
finalFocusEl | (() => MaybeElement) | undefined | — | Configures final focus el. |
restoreFocus | boolean | undefined | — | Configures restore focus. |
closeOnInteractOutside | boolean | undefined | true | Configures close on interact outside. |
closeOnEscape | boolean | undefined | true | Configures close on escape. |
role | "dialog" | "alertdialog" | undefined | — | Configures role. |
open | boolean | undefined | — | Whether the component is open when controlled. |
defaultOpen | boolean | undefined | — | Initial open state when uncontrolled. |
onOpenChange | ((details: OpenChangeDetails) => void) | undefined | — | Runs when open changes. |
triggerValue | string | null | undefined | — | Configures trigger value. |
defaultTriggerValue | string | null | undefined | — | Configures default trigger value. |
onTriggerValueChange | ((details: TriggerValueChangeDetails) => void) | undefined | — | Runs when trigger value changes. |
Context, Hooks, and Types
| Export | API |
|---|---|
DialogContext | Render-prop component that exposes component state and actions. |
DialogRootProvider | Provides an externally created API to the component tree. |
useDialog | Creates or accesses the component API. |
useDialogContext | Returns the nearest component API. |
DialogOpenChangeDetails | Type for the details object passed to the matching change callback. |
Angular
React
Solid
Svelte
Vue