Skip to content
Agent UI
PrimitivesDialog

Dialog

Uses HTML dialog.showModal for native focus trapping, Escape behavior and inert background semantics.

Dialog ships with a full API table, a copyable example, and accessibility notes.

tsx

Confirm action

This native dialog handles focus and Escape automatically.

Installation

Install the package once, then import Dialog from its direct entry point or from the root.

bash
pnpm add @agent-ui/react
tsx
import { Dialog } from "@agent-ui/react/dialog";

Tailwind CSS v4 users: add @source "../node_modules/@agent-ui/react/src" to the global stylesheet so the library utilities are generated.

Usage

The example below is the same code that renders the preview. Copy it, swap in your own handlers, and ship.

tsx
import { Dialog, DialogContent, DialogTitle, DialogDescription, DialogClose } from "@agent-ui/react";
 
<Dialog open={open} onOpenChange={setOpen}>
<DialogContent>
<DialogTitle>Continue?</DialogTitle>
<DialogDescription>Review the changes before confirming.</DialogDescription>
<DialogClose>Cancel</DialogClose>
</DialogContent>
</Dialog>

API reference

Every prop Dialog accepts, its type, default, and behaviour.

API reference for this component
NameTypeDefaultDescription
openboolean—Controlled visibility.
onOpenChange(open: boolean) => void—Open and close callback.

Accessibility

Use a heading (DialogTitle) or an explicit aria-label. Browser-native modal focus management is preserved.
Use it with the rest of the library

Dialog composes with MessageList, ChatShell, useChat, and the provider compose blocks. Browse the full reference or see all components in the gallery.

9 lines · copy-ready