Skip to main content

Dialog

A modal dialog with passive / transactional / danger variants.

Signature
Density
Viewport
Theme and light/dark are set in the top bar
Live demo
Open ↗

When to use​

  • Use it when A focused, interruptive task or confirmation that must be resolved before continuing.
  • Reach for something else when Non-blocking messages (use Alert/toast) or large workflows (use a page).

Accessibility​

Focus is trapped and returned to the trigger on close, Esc dismisses, and the backdrop is inert. Title wires aria-labelledby; variant="danger" still announces as a dialog.

Install and import​

npx shadcn@latest add @prism/dialog
import { Dialog } from '@/components/prism/Dialog';

In a no-build prototype, read it from the bundle instead: const { Dialog } = window.PrismDesignSystem_39d121;

Examples​

Transactional

<Dialog isOpen={open} onClose={close} title="Invite a member"
primaryLabel="Send invite" onPrimary={send}>
<TextField label="Email" type="email" />
</Dialog>

Danger

<Dialog isOpen={open} onClose={close} variant="danger" size="sm"
title="Delete workspace" primaryLabel="Delete" onPrimary={destroy}>
This can’t be undone.
</Dialog>

Props​

PropTypeRequiredDescription
isOpenbooleanYes
onClose() =&gt; void—
titleReact.ReactNode—
size"xs" | "sm" | "md" | "lg" | "full"—Width (a sheet's width too). "full" fills the viewport — a lightbox or media viewer.
placement"center" | "end"—"center" (default) or "end": a side sheet from the inline-end edge, full height (left edge in RTL).
backdrop"default" | "dark"—"dark": a near-black backdrop, and the dialog renders in the dark scheme (lightbox, media).
isTitleHiddenboolean—Keep the title for screen readers (it still names the dialog) but don't show it; the close × stays.
onPrevious() =&gt; void—ArrowLeft (ArrowRight in RTL) steps back — not while typing in a field.
onNext() =&gt; void—ArrowRight (ArrowLeft in RTL) steps forward — not while typing in a field.
variant"passive" | "transactional" | "danger"—Intent-based variant (Carbon approach): - "passive": informational, no actions, freely dismissable. - "transactional": requires a choice; background click won't dismiss. - "danger": transactional with a destructive primary action. Inferred from the action props when omitted.
primaryLabelstring—Primary action label — renders the standard footer.
onPrimary() =&gt; void—
secondaryLabelstring—Secondary/cancel label. Default "Cancel".
onSecondary() =&gt; void—
isPrimaryDisabledboolean—
dismissableboolean—Override whether scrim-click/Esc dismiss. Defaults by variant.
footerReact.ReactNode—Custom footer node (overrides the generated action buttons).
role"dialog" | "alertdialog"—Override the role. Default: "alertdialog" for variant="danger", else "dialog" (a form dialog is a dialog).
initialFocusRefReact.RefObject&lt;HTMLElement | null&gt;—The element to focus on open (e.g. a Cancel button). Focus still returns to the trigger on close — unlike autoFocus.
childrenReact.ReactNode—