Component
Modal
Dialog and AlertDialog are both modal overlays, wrapping Base UI. AlertDialog is for blocking confirmations that require an explicit choice.
Dialog
- Content takes mobileBehavior: dialog | sheet | fullscreen, implemented with CSS max-sm: variants
Alert dialog (destructive confirmation)
When to use
- The user must finish or explicitly dismiss a task before returning to the page (edit forms, confirmations, focused workflows).
- AlertDialog specifically: destructive or irreversible actions that need an explicit yes/no, not a passive notice.
When not to use
- Non-blocking status or a short message - use Toast or Notification instead.
- Content the user should be able to reference alongside the page - use Drawer or Popover instead.
- A simple yes/no that isn't destructive - a plain Dialog with two buttons is lighter than AlertDialog's stricter close semantics.
Keyboard
Mobile behavior
- mobileBehavior="dialog" (default): stays a centered card at every width - use for short content that doesn't benefit from more room.
- mobileBehavior="sheet": centered dialog on desktop, becomes a bottom-anchored full-width sheet under 640px - use for forms and taller content on mobile.
- mobileBehavior="fullscreen": centered dialog on desktop, becomes a fully fullscreen view under 640px - use for complex, multi-step, or scroll-heavy content on mobile.
- All three are pure CSS (max-sm: variants), so there's no layout flash or JS viewport check on first paint.
Accessibility notes
- Base UI applies role="dialog" (or role="alertdialog" for AlertDialog), aria-modal, and wires Dialog.Title/Dialog.Description to aria-labelledby/aria-describedby automatically.
- Focus moves into the dialog on open and returns to the trigger on close - verified by tabbing through Dialog.Trigger, opening, and closing with Escape.
- The backdrop is inert to screen readers and pointer events outside the dialog while open.
Common mistakes
- Omitting Dialog.Description for a form-heavy dialog - screen reader users get a title but no context for what they're editing.
- Using Dialog for a destructive action instead of AlertDialog - Dialog closes on outside click/Escape by default, which is exactly wrong for "delete this forever."
- Nesting a second modal dialog inside a dialog - stack Drawer or Popover instead if you need a secondary surface.
Known limitations
- No built-in scroll-lock exception for iOS Safari's rubber-band scroll; verify manually on longer dialog content.
Dialog.Content props
mobileBehavior"dialog"
"dialog" | "sheet" | "fullscreen"How the dialog presents under the sm: breakpoint. CSS-driven, no JS viewport check.
hideCloseButtonfalse
booleanHides the built-in top-right close button.
classNameNone
stringExtra classes merged onto the popup surface.
API reference
open / defaultOpenNone
booleanControlled or initial overlay state.
mobileBehavior"dialog"
dialog | sheet | fullscreenNarrow-screen presentation.
hideCloseButtonfalse
booleanHides the bare X dismiss control.
classNameNone
stringAdditional classes applied to the component root.
