Dialog
Open a modal for editing or confirmation.
Usage
Use a dialog for a focused task that needs the current page as context. Keep the title specific and provide a clear way to leave.
Accessibility
Include DialogTitle and DialogDescription. Escape closes and restores trigger focus. Focus stays inside while open. Use container for a locally themed portal.
| Property | Type | Default |
|---|---|---|
| open / defaultOpen | boolean | false |
| onOpenChange | (open: boolean) => void | None |
| theme (DialogContent) | light | dark | inherited |
| container (DialogContent) | HTMLElement | document.body |
<Dialog>
<DialogTrigger asChild><Button>Edit project</Button></DialogTrigger>
<DialogContent>
<DialogTitle>Project settings</DialogTitle>
<DialogDescription>Give your project a name.</DialogDescription>
<label htmlFor="name">Name</label>
<Input id="name" defaultValue="Interaction Inspector" />
<DialogClose asChild><Button>Done</Button></DialogClose>
</DialogContent>
</Dialog>