Dialog
unreleasedstable
A modal surface that interrupts the page for focused decisions or forms.
import {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogPanel,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
export function Component() {
return (
<Dialog>
<DialogTrigger type="button">Open dialog</DialogTrigger>
<DialogContent class="sm:w-96">
<DialogHeader>
<DialogTitle>Edit profile</DialogTitle>
<DialogDescription>
Make changes to your profile here. Click save when you're done.
</DialogDescription>
</DialogHeader>
<DialogPanel class="grid gap-4">
<label class="grid gap-2 text-sm font-medium">
Name
<Input defaultValue="Margaret Welsh" />
</label>
<label class="grid gap-2 text-sm font-medium">
Username
<Input defaultValue="@maggie.welsh" />
</label>
</DialogPanel>
<DialogFooter>
<DialogClose as={Button} type="button" variant="ghost">
Cancel
</DialogClose>
<Button type="button">Save</Button>
</DialogFooter>
</DialogContent>
</Dialog>
);
}Dialog
Root owner for modal state, dismissal, and focus behavior.
DialogTrigger
Button-like trigger that opens the dialog.
DialogContent
Portaled overlay content with backdrop, positioner, panel, and close affordance.
DialogTitle
Accessible title associated with the dialog content.
DialogDescription
Accessible description associated with the dialog content.