Components
Dialog
A modal for a short form or a result that needs the user's whole attention.
bunx shadcn@latest add @nalarx/dialogUsage
<Dialog open={open} onOpenChange={setOpen}>
<DialogContent showCloseButton>
<DialogHeader>
<DialogTitle>Rename dashboard</DialogTitle>
<DialogDescription>The new name shows in the sidebar.</DialogDescription>
</DialogHeader>
{/* fields */}
<DialogFooter>
<DialogClose render={<Button variant="ghost" />}>Cancel</DialogClose>
<Button variant="accent" onClick={save}>Save</Button>
</DialogFooter>
</DialogContent>
</Dialog>A form dialog with the close X, and a centred one without it. The popup opens in the docs page's own scheme.
For alert, confirm and prompt, use App dialog instead of building one.
States
- Open: grows from 97% while the backdrop fades in; leaves a little faster than it came. No motion under reduced motion.
- Tall content: the viewport layer scrolls; the popup keeps its top anchor.
- Phones: the popup takes the width minus 16px each side; the close X grows to 36px.
Keyboard
| Key | |
|---|---|
Tab / Shift+Tab | Moves through the dialog only; focus never leaves it while open. |
Escape | Closes and returns focus to the trigger. |
Enter / Space on a trigger | Opens; focus moves to the first focusable element, or to initialFocus. |
Pointer: a press outside the popup closes it, unless disablePointerDismissal is set on Dialog.
Props
Dialog takes Base UI Dialog.Root props (open, onOpenChange, defaultOpen, modal, disablePointerDismissal). DialogContent takes Dialog.Popup props (initialFocus, finalFocus, className) plus:
| Prop | Type | Default | |
|---|---|---|---|
showCloseButton | boolean | false | The X in the top-right corner. |
closeLabel | string | close string | Accessible name of the X. |
align | "top" | "center" | "top" | top lets a growing form extend downward. |
dialogBackdropClass is the backdrop's class list for a hand-built overlay.
Replaces
Platform base/Dialog.tsx; dialogBackdrop.ts in both apps (DIALOG_BACKDROP_CLASS becomes a re-export of dialogBackdropClass).