Dialog presents content in a modal layer above the page. The native dialog element manages focus and the Escape key. Its state can be controlled or uncontrolled. Animations respect reduced motion preferences.
Browser support
Feature
Baseline
Your browser
<dialog>
Native modal window.
Your browser:
@starting-style
Entry animation.
Your browser:
transition-behavior
Exit animation.
Your browser:
Preview
Installation
Usage
import { Dialog, DialogTrigger, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter, DialogClose } from "@/components/ui/dialog"
import { Button } from "@/components/ui/button"
<Dialog>
<DialogTrigger asChild><Button>Open</Button></DialogTrigger>
<DialogContent>
<DialogHeader><DialogTitle>Profile settings</DialogTitle><DialogDescription>Update your settings.</DialogDescription></DialogHeader>
<DialogFooter><DialogClose asChild><Button>Close</Button></DialogClose></DialogFooter>
</DialogContent>
</Dialog>Examples
Basic
import { Dialog, DialogTrigger, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter, DialogClose } from "@/components/ui/dialog"
import { Button } from "@/components/ui/button"
<Dialog>
<DialogTrigger asChild><Button>Open</Button></DialogTrigger>
<DialogContent>
<DialogHeader><DialogTitle>Profile settings</DialogTitle><DialogDescription>Update your settings.</DialogDescription></DialogHeader>
<DialogFooter><DialogClose asChild><Button>Close</Button></DialogClose></DialogFooter>
</DialogContent>
</Dialog>With a form
<Dialog>
<DialogTrigger asChild><Button>Edit profile</Button></DialogTrigger>
<DialogContent>
<DialogHeader><DialogTitle>Edit profile</DialogTitle><DialogDescription>Update your name.</DialogDescription></DialogHeader>
<form onSubmit={handleSubmit}><label>Name <Input name="name" /></label><Button type="submit">Save</Button></form>
</DialogContent>
</Dialog>Controlled
const [open, setOpen] = React.useState(false)
<Dialog open={open} onOpenChange={setOpen}>
<DialogTrigger asChild><Button>Open</Button></DialogTrigger>
<DialogContent><DialogTitle>Settings</DialogTitle><DialogDescription>Manage your settings.</DialogDescription></DialogContent>
</Dialog>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| open | boolean | - | Controlled open state. |
| defaultOpen | boolean | false | Initial open state. |
| onOpenChange | (open: boolean) => void | - | Called when open state changes. |
| asChild | boolean | false | Composes Trigger or Close with its child. |
| showCloseButton | boolean | true | Shows the close button. |
| className | string | - | Additional CSS classes. |