Skip to content

Dialog

Modal surface for focused tasks — forms, details, and short flows. Use alert dialog when the action is destructive or irreversible.

Examples

Basic

Overview

Dialog opens a centered popup over a backdrop. Compose portal, backdrop, popup, title, description, and close. Style triggers and closes with Button via Base UI's render prop.

tsx

import {
  Button,
  Dialog,
  DialogTrigger,
  DialogPortal,
  DialogBackdrop,
  DialogPopup,
  DialogTitle,
  DialogDescription,
  DialogClose,
} from "@standard-ui/react"

<Dialog>
  <DialogTrigger render={<Button />}>Open dialog</DialogTrigger>
  <DialogPortal>
    <DialogBackdrop />
    <DialogPopup>
      <DialogTitle>Edit profile</DialogTitle>
      <DialogDescription>
        Make changes to your profile.
      </DialogDescription>
      <DialogClose render={<Button variant="outline" />}>
        Close
      </DialogClose>
    </DialogPopup>
  </DialogPortal>
</Dialog>

Usage

Trigger and close

Pass Button through render so the control keeps Standard UI styles without nesting buttons.

tsx

<DialogTrigger render={<Button />}>Open dialog</DialogTrigger>
<DialogClose render={<Button variant="outline" />}>Close</DialogClose>

Structure

Always include a title. Description is optional but recommended for context. Put primary and secondary actions in a trailing row inside the popup.

tsx

<DialogPopup>
  <DialogHeader>
    <DialogTitle>Edit profile</DialogTitle>
    <DialogDescription>
      Update your name and email address.
    </DialogDescription>
  </DialogHeader>
  {/* form fields + actions */}
</DialogPopup>

API

Parts mirror Base UI Dialog. Prefer render={<Button />} on trigger and close for consistent button styles.

PartRole
DialogRoot state and open control.
DialogTriggerOpens the dialog. Use Button via render.
DialogPortalRenders overlay content outside the tree.
DialogBackdropDimmed layer behind the popup.
DialogPopupCentered surface for title, body, and actions.
DialogHeaderGroups title and description with tight spacing.
DialogTitleAccessible dialog title.
DialogDescriptionSupporting explanation.
DialogCloseDismisses the dialog. Style with Button.

Guidelines

Do

  • Use dialogs for focused tasks that need the page blocked
  • Provide a clear title and an obvious dismiss action
  • Prefer alert dialog for discard, delete, and other high-risk confirms

Don't

  • Don't nest a Button inside DialogTrigger — use render
  • Don't open dialogs for content that belongs on a full page
  • Don't leave the popup without a title for screen readers