Skip to content
Logic2BUI

Search docs

Search components and documentation

New
Menu

Dialog

A window overlaid on the primary window, rendering content that requires the user's attention.

Installation

npx logic2b@next add dialog

Usage

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

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.
  • DialogTitle is required for an accessible name — pair it with DialogDescription (wire both to the content via aria-labelledby / aria-describedby, which Radix handles automatically).
  • Escape and an overlay click both dismiss the dialog; the close button ships an sr-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.

View JSON

Dialog

Component
Props: React.ComponentProps<typeof DialogPrimitive.Root>

DialogClose

Component
Props: React.ComponentProps<typeof DialogPrimitive.Close>

DialogContent

Component
Props: React.ComponentProps<typeof DialogPrimitive.Content> & { showCloseButton?: boolean }
PropTypeRequiredDefaultDescription
showCloseButtonbooleanNotrue—

DialogDescription

Component
Props: React.ComponentProps<typeof DialogPrimitive.Description>

DialogFooter

Component
Props: React.ComponentProps<"div">

DialogHeader

Component
Props: React.ComponentProps<"div">

DialogOverlay

Component
Props: React.ComponentProps<typeof DialogPrimitive.Overlay>

DialogPortal

Component
Props: React.ComponentProps<typeof DialogPrimitive.Portal>

DialogTitle

Component
Props: React.ComponentProps<typeof DialogPrimitive.Title>

DialogTrigger

Component
Props: React.ComponentProps<typeof DialogPrimitive.Trigger>

Accessibility contract

Machine-readable behavior and consumer responsibilities for dialog.

View JSON
Support
Primitive-managed
Pattern
modal dialog
Radix Dialog
Keyboard interactions for dialog
KeysBehavior
EscapeClose the open surface and restore focus.
Tab Shift+TabCycle 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.