Installation
npx logic2b@next add dialogUsage
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog"
<Dialog>
<DialogTrigger>Open</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>Are you absolutely sure?</DialogTitle>
<DialogDescription>
This action cannot be undone.
</DialogDescription>
</DialogHeader>
</DialogContent>
</Dialog>
Examples
Share Link
Controlled
Drive the open state yourself to confirm a destructive action.
Accessibility
- Built on Radix Dialog: focus is trapped inside the content and returns to the trigger on close.
DialogTitleis required for an accessible name — pair it withDialogDescription(wire both to the content viaaria-labelledby/aria-describedby, which Radix handles automatically).Escapeand an overlay click both dismiss the dialog; the close button ships ansr-only“Close” label.
Live playground
Edit the component props and inspect the exact JSX before copying it. The preview loads only when this section enters the viewport.
Generated JSX
<Dialog>
<DialogTrigger
className="rounded-md border px-4 py-2 text-sm font-medium"
>Edit project</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>Edit project</DialogTitle>
<DialogDescription>Update the project details, then save your changes.</DialogDescription>
</DialogHeader>
<label
className="grid gap-2 text-sm"
>
<span>Project name</span>
<input
type="text"
defaultValue="logic2b ui"
className="h-9 rounded-md border px-3"
/>
</label>
<DialogFooter>
<DialogClose
className="rounded-md border px-4 py-2 text-sm font-medium"
>Save changes</DialogClose>
</DialogFooter>
</DialogContent>
</Dialog>API reference
Generated from the public TypeScript exports in src/ui/dialog.tsx.
Dialog
ComponentProps: React.ComponentProps<typeof DialogPrimitive.Root>DialogClose
ComponentProps: React.ComponentProps<typeof DialogPrimitive.Close>DialogContent
ComponentProps: React.ComponentProps<typeof DialogPrimitive.Content> & { showCloseButton?: boolean }| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
showCloseButton | boolean | No | true | — |
DialogDescription
ComponentProps: React.ComponentProps<typeof DialogPrimitive.Description>DialogFooter
ComponentProps: React.ComponentProps<"div">DialogHeader
ComponentProps: React.ComponentProps<"div">DialogOverlay
ComponentProps: React.ComponentProps<typeof DialogPrimitive.Overlay>DialogPortal
ComponentProps: React.ComponentProps<typeof DialogPrimitive.Portal>DialogTitle
ComponentProps: React.ComponentProps<typeof DialogPrimitive.Title>DialogTrigger
ComponentProps: React.ComponentProps<typeof DialogPrimitive.Trigger>Accessibility contract
Machine-readable behavior and consumer responsibilities for dialog.
- Support
- Primitive-managed
- Pattern
- modal dialog
- Radix Dialog
| Keys | Behavior |
|---|---|
| Escape | Close the open surface and restore focus. |
| Tab Shift+Tab | Cycle focus inside the modal surface. |
Built-in semantics
- Content is a dialog, traps focus and restores it to the trigger on close.
- Title and description wire aria-labelledby and aria-describedby.
Consumer responsibilities
- Always render DialogTitle; add DialogDescription when explanatory copy exists.