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
| Prop | Type | Default | Description |
|---|---|---|---|
| Dialog.open / defaultOpen | boolean | — | 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.container | HTMLElement | null | document.body | Optional portal container element for the dialog itself. |
Sizes and tokens
| Tier / Role | Token | Value |
|---|---|---|
| sm | max-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 |
| lg | max-w-[min(48rem,calc(100vw-2rem))] | 768px max width · 16px viewport margin |
| Surface & radius | --card / --radius-xl / --shadow-xl / --space-6 | 24px radius · 24px padding · shadow-xl · z-modal (40) |
| Scrim | --overlay / --z-overlay | Obsidian at fixed alpha per mode · no backdrop-blur · z-index 30 |
| Motion | --duration-162 / --duration-100 | Fade + 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
DialogContentsetsaria-modal="true",aria-labelledby(viaDialogTitle), andaria-describedby(viaDialogDescription).- Focus moves into the dialog on open, stays trapped across
Tab/Shift+Tab, and returns toDialogTriggeron close. Escapeand scrim clicks dismiss the dialog; the close button is aghosticonButtonwitharia-label="Close".- Nested
Select,Popover, andTooltipinstances 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.