About the shadcn/ui Dialog Component

The Dialog component is part of shadcn/ui — a collection of accessible, copy-paste React components built with Radix UI and Tailwind CSS. Install it with `npx shadcn@latest add dialog` and copy it directly into your project.

Dialog Component — Frequently Asked Questions

How do I prevent a shadcn Dialog from closing on outside click?

Add `onInteractOutside={(e) => e.preventDefault()}` to `<DialogContent>`. This keeps the dialog open unless the user clicks a close button.

How do I put a form inside a shadcn Dialog?

Place your form and submit button inside `<DialogContent>`. Use `<DialogFooter>` for the action buttons and handle form state in the parent component.

How do I control a shadcn Dialog programmatically?

Use the `open` and `onOpenChange` props: `<Dialog open={open} onOpenChange={setOpen}>`. Manage state with `useState` in the parent.

Dialog Component - shadcn/ui Examples | Shadcn Store