Dialog
dialogA modal built on the Base UI primitive, so the focus trap, the inert background, Esc to close and the return of focus all come from one well tested place. The backdrop fades and the panel scales in, both in and out, and everything comes from the foundation tokens.
import { X } from "lucide-react";
import { Button } from "@/components/forme/button/button";
import { Input } from "@/components/forme/input/input";
import {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/forme/dialog/dialog";
export function DialogDemo() {
return (
<div className="flex flex-col gap-8">
<Dialog>
<DialogTrigger asChild>
<Button variant="secondary">Rename workspace</Button>
</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>Rename workspace</DialogTitle>
<DialogDescription>
The new name is visible to everyone in the workspace, and old links still resolve.
</DialogDescription>
</DialogHeader>
<Input label="Workspace name" defaultValue="acme" />
<DialogFooter>
<DialogClose asChild>
<Button variant="ghost">Cancel</Button>
</DialogClose>
<DialogClose asChild>
<Button>Save</Button>
</DialogClose>
</DialogFooter>
<DialogClose
aria-label="Close"
className="absolute top-4 end-4 rounded-md p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground"
>
<X />
</DialogClose>
</DialogContent>
</Dialog>
<Dialog>
<DialogTrigger asChild>
<Button variant="danger">Delete deployment</Button>
</DialogTrigger>
<DialogContent className="max-w-sm">
<DialogHeader>
<DialogTitle>Delete web-2.4.0?</DialogTitle>
<DialogDescription>
Traffic moves to the previous deployment. The logs stay readable for thirty days.
</DialogDescription>
</DialogHeader>
<DialogFooter>
<DialogClose asChild>
<Button variant="ghost">Keep it</Button>
</DialogClose>
<DialogClose asChild>
<Button variant="danger">Delete</Button>
</DialogClose>
</DialogFooter>
</DialogContent>
</Dialog>
</div>
);
}Install
Adds the component, its registry dependencies, and the token stylesheet you import once.
Usage
import {
Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger,
} from "@/components/forme/dialog/dialog";
<Dialog>
<DialogTrigger asChild>
<Button variant="secondary">Rename workspace</Button>
</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>Rename workspace</DialogTitle>
<DialogDescription>Old links still resolve.</DialogDescription>
</DialogHeader>
</DialogContent>
</Dialog>When to use
Reach for it
- A task that has to be finished or dismissed before going on: a short form, a decision that needs context.
Use something else
- A quick confirmation of something undoable — do it and offer Undo in a toast.
- Long or multi-step flows that deserve their own page.
- Panels on a phone that should come up from the bottom; use the
Drawer.
API reference
Read from the source, so it is the API of the file you install. A prop marked * is required.
DialogTrigger
| Prop | Type | Default | Description |
|---|---|---|---|
asChild | boolean | — | Render as the single child element instead of a <button>, keeping the open behaviour. |
Also takes every prop of Base UI Dialog.Trigger.
DialogClose
| Prop | Type | Default | Description |
|---|---|---|---|
asChild | boolean | — | Render as the single child element instead of a <button>, keeping the close behaviour. |
Also takes every prop of Base UI Dialog.Close.
The other parts
DialogTakes Base UIDialog.RootDialogPortalTakes Base UIDialog.PortalDialogBackdropTakes Base UIDialog.BackdropDialogContentTakes Base UIDialog.PopupDialogHeaderTakes<div>attributesDialogFooterTakes<div>attributesDialogTitleTakes Base UIDialog.TitleDialogDescriptionTakes Base UIDialog.Description
Accessibility
- Base UI traps focus inside, makes the page behind it inert, closes on Esc and returns focus to the trigger.
DialogTitleandDialogDescriptionname and describe it for screen readers; keep both.
Motion
- The scrim fades and the panel pops in on the standard duration, and both leave faster than they arrived.
Responsive behaviour
- The panel is capped at
max-w-mdand the footer's buttons stack belowsm.
Related


Drawer
A bottom sheet on the Base UI dialog, so it keeps the focus trap, Esc and focus return. Drag it down by the handle or header and it follows your finger, then springs back or closes when pulled past a third of its height or flicked.
overlays

Dropdown
A menu of actions revealed from a trigger. Grouped, with labels, a destructive variant, checkbox items, and full keyboard and typeahead support from the Base UI menu primitive — Forme adds only the surface and the motion.
overlays

Lightbox
A photo gallery whose thumbnails fly into a full-screen viewer and back again. Arrow keys, a thumbnail strip and swipe move between photos, and it is a Base UI dialog underneath, so focus is trapped and returns to the thumbnail you opened.
overlays