Dialog
A modal surface that takes the window until it is dismissed
Installation
npx shadcn@latest add @sudokw/components-dialogimport { Dialog } from "@gpuixui/components";Usage
import {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@gpuixui/components/dialog";
import { Button } from "@gpuixui/primitives";
<Dialog>
<DialogTrigger>Delete workspace</DialogTrigger>
<DialogContent label="Delete workspace">
<DialogHeader>
<DialogTitle>Delete this workspace?</DialogTitle>
<DialogDescription>
The workspace and its 42 files are removed for everyone.
</DialogDescription>
</DialogHeader>
<DialogFooter>
<DialogClose>Cancel</DialogClose>
<Button variant="destructive">Delete workspace</Button>
</DialogFooter>
</DialogContent>
</Dialog>;Composition
Dialog
├── DialogTrigger
└── DialogContent
├── DialogHeader
│ ├── DialogTitle
│ └── DialogDescription
├── DialogFooter
│ └── DialogClose
└── (close control)API reference
Dialog
| Prop | Type | Default |
|---|---|---|
open | boolean | uncontrolled |
defaultOpen | boolean | false |
onOpenChange | (open: boolean) => void | none |
dismissible | boolean | true |
children | parts — DialogTrigger, DialogContent, DialogClose | — |
DialogContent
| Prop | Type | Default |
|---|---|---|
label | string (required) | none |
role | "dialog" | "alertdialog" | "dialog" |
size | "sm" | "md" | "lg" | "md" — a stored name the union does not carry |
showClose | boolean | true |
initialFocus | () => number | null | none |
className | string — joined after the surface recipe | — |
children | ReactNode — the surface's content | — |
DialogTrigger and DialogClose
| Prop | Type | Default |
|---|---|---|
disabled | boolean | false |
onClick | (event: EventPayload) => void | none |
variant | "primary" | "secondary" | "ghost" | "danger" | "secondary" |
size | "sm" | "md" | "lg" | "md" |
loading, loadingLabel, reducedMotion, leading, trailing | the shared Button busy contract | — |
className | string — joined after the button recipe | none |
Theming
The box paints the theme's elevation.lg beside its 1px foreground ring. Its corner is the recipe's fixed 32px (rounded-4xl); the preview draws the platform radius plus 8px and is the approximation.
Keyboard
- Escape
- dismisses the topmost overlay
- Tab
- keeps focus inside the dialog, wrapping with `Shift+Tab`
read from modal.ts
Edit this page on GitHubapps/docs/content/docs/components/dialog.mdx