4.2.0
Core

Dialog

A modal that suspends the page for one job — and can always be abandoned without doing it.

Dialog

One job, taken out of the page and handed back when it is done or abandoned. Reach for it when the reader cannot usefully do anything else until they have finished or dropped this — and when dropping it is allowed, which is what separates it from `AlertDialog`.

Usage

import {
  Dialog,
  DialogClose,
  DialogContent,
  DialogDescription,
  DialogFooter,
  DialogHeader,
  DialogOverlay,
  DialogPortal,
  DialogTitle,
  DialogTrigger,
} from '@oceanic-hub/brand-system'
<Dialog>
  <DialogTrigger>…</DialogTrigger>
  <DialogContent>
    <DialogHeader>
      <DialogTitle>…</DialogTitle>
      <DialogDescription>…</DialogDescription>
    </DialogHeader>
    <DialogFooter>
      <DialogClose>…</DialogClose>
    </DialogFooter>
  </DialogContent>
</Dialog>

Composition

Use the following composition to build a Dialog:

Dialog
├── DialogTrigger
└── DialogContent
    ├── DialogHeader
    │   ├── DialogTitle
    │   └── DialogDescription
    └── DialogFooter
        └── DialogClose

Reach for it when the reader cannot usefully do anything else until this is finished or dropped: a short form, a confirmation whose answer changes what they are looking at, a detail too big for a Popover. One job — a dialog that has grown a second decision has become a page that forgot to get a URL.

Both halves of that sentence are load-bearing, because the rest of the family is defined against them. It suspends the page, so anything the page can stay usable behind is not a dialog: that is a Popover for a small surface, a DropdownMenu for two or three toggles, an EntityDrawer for a detail panel beside a list that keeps working. And it can always be abandoned — the scrim, Escape and the built-in close all mean the same thing — so anything the reader must not be able to walk away from is an AlertDialog, which removes every exit that is not a choice. When the job simply needs more room than a centred box, it is a Sheet; when it should be thrown away with a thumb, it is a Drawer.

The title is the question and the confirm button says what will happen — "Delete staging permanently", not "OK". A dialog whose buttons say Yes and No has moved the decision into the title and then hidden it. DialogTitle is also the accessible name, so it is never optional: Radix warns at runtime without one, and a design with no visible heading keeps the element and hides it with sr-only.

One composition mistake this family invites. DialogContent renders its own portal and its own overlay, and both parts are exported anyway — Radix names them and a reader arriving from shadcn goes looking. So the canonical shadcn arrangement, portal wrapping overlay wrapping content, typechecks here and paints two scrims one over the other. Root, trigger, content: that is the whole composition, and no type can say so, which is why it is said here.

A dialog opened from a menu item is the other trap. The menu unmounts as it closes and takes the trigger with it, so the dialog never opens — hold open yourself and render the dialog as a sibling of the menu rather than inside it.

What upstream shows that does not come across. showCloseButton={false} belongs to its Base UI generation; here the close is built into DialogContent rather than slotted, deliberately, because a modal a reader may walk away from should show them the door. For the same reason the X is not a slot to be replaced: a second, labelled way out belongs in the footer as a DialogClose. Upstream also demonstrates a sticky footer and a scrolling body as two examples; with this content's grid they are one arrangement, so they are one section here. And RTL is not supported — nothing in this package has been laid out or measured right-to-left, and the refusal is written down in pairings.json under direction rather than left to be discovered.

Locked during submit

Regla 2 of the pending-state doctrine: while a submit is in flight the dialog locks — backdrop, Escape and the X all stop dismissing it, Cancel disables with the same signal, and a failure surfaces INLINE instead of closing the dialog on you.

Scrolling body

Cap the height and let the middle scroll, so the title stays readable and the buttons stay reachable however long the content is. Reach for it when the reader has to read to decide — terms, release notes, a diff — and never as a way to fit more into a dialog that should be a page.

Naming the close button

The corner button's screen-reader text was the literal string "Close" for every dialog everywhere. That is a fine default and a bad constant: read out in a list of buttons, "Close" does not say close WHAT. closeLabel lets a distinctly named surface name its own exit, and defaults to Close so nothing moves unless you have something better to say. SheetContent takes the same prop — the two draw the same corner button, and a name available on one and not the other is an asymmetry a consumer discovers rather than reads.

API Reference

See the Dialog API page for every prop of every part, with types, defaults and the contract that pins them.

On this page