GitHubX

Dialog

<modal />

Definition

A dialog is a modal surface that appears above the page to capture focused attention for a task, decision, or message. It dims or blocks the content behind it and returns the user to their prior context when dismissed.

The pattern is interruptive focus: use when the user must acknowledge, confirm, or complete something before continuing. Unlike inline panels, a dialog pauses the underlying workflow until it is closed.

Also known as

People also call this a modal, modal dialog, or popup (informally). Alert dialog usually means a system-style confirmation with limited actions. Lightbox often refers to image or media overlays, though the interaction model is similar. Drawer and sheet are related patterns that slide in from an edge rather than centering on screen. In code libraries, dialog or modal are the most common names.

Component Anatomy

PartRole
RootState container — open/closed, controlled or uncontrolled
TriggerControl that opens the dialog (button, link, menu item)
PortalRenders overlay and content outside the DOM hierarchy to avoid clipping
OverlayFull-screen backdrop — dims page content and signals modality
ContentCentered panel — title, body, and actions
HeaderGroups title and description at the top
TitlePrimary heading — names the dialog's purpose
DescriptionSupporting text — often muted, explains consequences or context
FooterBottom action row — confirm, cancel, secondary links
CloseDismiss control — icon button in the corner and/or explicit cancel action

When to use it

Use a dialog when the user needs a short, focused interaction without leaving the current page:

  • Confirmations — delete account, discard unsaved changes, submit irreversible action
  • Quick forms — edit a single record, add a note, invite a teammate
  • Alerts — error summary, success acknowledgment, permission request
  • Detail on demand — expand an item for more context without full navigation
  • Media preview — enlarge an image or video in a lightbox-style overlay

Avoid a dialog when the content is long or multi-step (use a dedicated page or wizard), when users need to reference the page behind while working (use a side panel or inline expansion), or for non-blocking information (use a toast or inline banner). Do not stack dialogs on top of dialogs — combine steps or navigate to a full-page flow instead.

Modal dialogs block interaction with the page until dismissed. Non-modal dialogs are rare in web UI; prefer a popover or drawer when background interaction should remain available. Keep copy short; if the body scrolls extensively, the pattern has likely outgrown a dialog.

Component Anatomy

Dialog
DialogOverlay
DialogContent
DialogClose
DialogHeader
DialogTitle
DialogDescription
DialogFooter
DialogTrigger

Opens the dialog — usually a button or link

Labeled diagram of dialog parts: Dialog root, DialogTrigger, DialogOverlay backdrop, DialogContent panel with DialogHeader, DialogTitle, DialogDescription, body content, optional DialogFooter actions, and DialogClose control.
Edit this page on GitHub