Skip to content
ComponentsMarkdown

Dialog

Centered modal overlay powered by Radix Dialog. Traps keyboard focus, dims the background with the Obsidian --overlay scrim, and provides a portal container for nested popups.

Live example

Props

PropTypeDefaultDescription
Dialog.open / defaultOpenboolean—Controlled or uncontrolled open state on the Dialog root.
DialogContent.size"sm" | "md" | "lg""md"Maximum width tier: sm 384px, md 512px, lg 768px (capped at 100vw − 32px).
DialogContent.containerHTMLElement | nulldocument.bodyOptional portal container element for the dialog itself.

Sizes and tokens

Tier / RoleTokenValue
smmax-w-[min(24rem,calc(100vw-2rem))]384px max width · 16px viewport margin
md (default)max-w-[min(32rem,calc(100vw-2rem))]512px max width · 16px viewport margin
lgmax-w-[min(48rem,calc(100vw-2rem))]768px max width · 16px viewport margin
Surface & radius--card / --radius-xl / --shadow-xl / --space-624px radius · 24px padding · shadow-xl · z-modal (40)
Scrim--overlay / --z-overlayObsidian at fixed alpha per mode · no backdrop-blur · z-index 30
Motion--duration-162 / --duration-100Fade + scale 0.96→1 (162ms enter, 100ms exit); opacity-only when reduced

States

Code

import {
  Button,
  Dialog,
  DialogClose,
  DialogContent,
  DialogDescription,
  DialogFooter,
  DialogHeader,
  DialogTitle,
  DialogTrigger,
} from "@freshgemui/monoplinth";

export function Example() {
  return (
    <Dialog>
      <DialogTrigger asChild>
        <Button>Open dialog</Button>
      </DialogTrigger>
      <DialogContent size="md">
        <DialogHeader>
          <DialogTitle>Confirm action</DialogTitle>
          <DialogDescription>
            Review changes before publishing.
          </DialogDescription>
        </DialogHeader>
        <DialogFooter>
          <DialogClose asChild>
            <Button variant="outline">Cancel</Button>
          </DialogClose>
          <Button>Confirm</Button>
        </DialogFooter>
      </DialogContent>
    </Dialog>
  );
}

Do and don't

Do: Always render DialogTitle inside DialogContent
DialogTitle provides the accessible heading wired to aria-labelledby so screen readers announce the modal purpose.
Don't: Apply backdrop-blur to the scrim
Do not add frosted glass or blur effects behind modals; Monoplinth uses a solid Obsidian alpha scrim (--overlay).

Accessibility

  • DialogContent sets aria-modal="true", aria-labelledby (via DialogTitle), and aria-describedby (via DialogDescription).
  • Focus moves into the dialog on open, stays trapped across Tab / Shift+Tab, and returns to DialogTrigger on close.
  • Escape and scrim clicks dismiss the dialog; the close button is a ghost icon Button with aria-label="Close".
  • Nested Select, Popover, and Tooltip instances portal into the dialog's internal container so they stay interactive and unclipped.

Rationale

Providing a portal container inside DialogContent keeps nested popups inside Radix's focus and dismissal boundary while rendering above the modal surface without z-index escalation.