Dialog
Grows out of the button that opened it and shrinks back into it. Focus is trapped inside and handed back when it closes.
npx shadcn@latest add @captain/dialogAtlas, spend today
$12.84 of $40.00
Dialog is a Pro component
The demo and the docs are free. The source comes with Pro, through this page, the shadcn CLI and the MCP.
Usage
import { Dialog, DialogTrigger, DialogContent, DialogClose } from "@/components/ui/dialog"
<Dialog>
<DialogTrigger>Change cap</DialogTrigger>
<DialogContent title="Daily spend cap" description="Atlas pauses at the cap.">
…
<DialogClose>Cancel</DialogClose>
</DialogContent>
</Dialog>Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| Dialog open | boolean | Controlled open state. Pair with onOpenChange. | |
| Dialog defaultOpen | boolean | false | Initial state when uncontrolled. |
| DialogTrigger | button props | Opens the dialog and becomes its transform origin. | |
| DialogContent title | ReactNode | Required. Wired to aria-labelledby. | |
| DialogContent description | ReactNode | Wired to aria-describedby. | |
| DialogContent dismissible | boolean | true | Close on a click on the scrim. |
| DialogClose | button props | Closes the dialog. |
Keyboard
- Tab / Shift+Tab
- Cycle inside the dialog
- Esc
- Close and return focus to the trigger
Accessibility
- role=dialog with aria-modal, aria-labelledby and aria-describedby.
- Focus moves to the first field (or [data-autofocus]) and is trapped until close.
- Focus returns to whatever opened it. The page behind cannot scroll.