This page as markdown: /dialog.md · Index for agents: /llms.txt · Everything in one file: /llms-full.txt

Dialog

Status: stable

Modal surface over Base UI Dialog (focus trap, scroll lock, Esc/outside dismissal). Centered on desktop; max-width 500px. size="fullscreen" is the full-bleed media viewer (image, video, Carousel) over a near-opaque scrim.

Keywords: dialog, modal, overlay, confirmation, alert, form, focus trap, sheet, lightbox, fullscreen, image viewer, media overlay, gallery

Usage

Use Dialog for focused decisions, short modal forms, confirmations, and content that temporarily blocks the underlying page. Prefer Sheet for side-panel workflows, Popover for lightweight anchored content, and inline sections for content that should remain part of the page.

Best practices

Anatomy

Part Required Description
Trigger no The element that opens the dialog when using the composed trigger pattern.
Overlay yes The dimming backdrop behind the modal content.
Content yes The modal surface that receives focus trap, labelled-by, and described-by wiring.
Header yes Title and optional description that explain the decision or task.
Footer no Action row for cancel, confirm, submit, or destructive choices.

Subcomponents

Name Type Description
DialogContent Base UI Popup props (initialFocus, finalFocus) + size?: "default" | "fullscreen" + showCloseButton?: boolean + closeLabel?: string + scroll?: boolean + keepMounted?: boolean + className Backdrop + popup; portals to . Composes DialogOverlay by default. size="fullscreen" is the media viewer: a near-opaque scrim (bg-overlay/95), an edge-to-edge popup that centres its children with no card chrome, motion-fade instead of motion-pop, and a safe-area-aware floating close button (Button variant="floating"); at that size showCloseButton defaults to true and scroll to false, and the media fits itself with max-h-full max-w-full object-contain. At the default size, showCloseButton (defaults to false) renders a built-in close (X) button in the top-end corner, and the header leaves room for it (Icon name="xmark"). closeLabel (default "Close") is that button's accessible name at either size; its hit area grows to 44px under a coarse pointer without moving it. The popup caps at the viewport height less a 1rem margin and wraps its children in a scrolling region, so a tall dialog scrolls instead of overflowing a viewport whose own scroll is locked; pass scroll={false} when the dialog owns its internal layout (a pinned header over a scrolling body) and supplies its own min-h-0 scroll region. keepMounted (default false) keeps the content mounted and hidden while closed, so a draft survives close and reopen. finalFocus defaults to the element focused when the dialog opened, trigger or not; an explicit finalFocus (a ref, a function, or false) wins.
DialogOverlay Base UI Backdrop props + size?: "default" | "fullscreen" + className The styleable scrim/backdrop — bg-overlay/(--scrim-alpha) by default (50% light, 72% dark, so it dims a near-black page as visibly as a white one), near-opaque bg-overlay/95 at size="fullscreen". Composed into DialogContent (at the matching size) by default; exported for manual styling.
DialogTrigger Base UI Dialog.Trigger props (render) Element that opens the dialog. Compose via render prop.
DialogClose Base UI Dialog.Close props (render) Element that dismisses the dialog. Compose via render prop.
DialogHeader ComponentProps<"div"> Top section holding DialogTitle/DialogDescription.
DialogTitle Base UI Dialog.Title props + className The dialog's accessible name — wires aria-labelledby on the popup.
DialogDescription Base UI Dialog.Description props + className Muted supporting line; wires aria-describedby.
DialogFooter ComponentProps<"div"> Bottom action row (right-aligned buttons).
AlertDialog (Root) Base UI AlertDialog.Root props (open, defaultOpen, onOpenChange) Root for a confirmation that needs an answer. Always modal; the popup is role="alertdialog" and a click outside does not dismiss — only an AlertDialogClose, an action that sets open to false, or Esc. Returns focus on close to the element focused when it opened, exactly as Dialog does.
AlertDialogTrigger Base UI AlertDialog.Trigger props (render) Opens the alert dialog.
AlertDialogContent / AlertDialogOverlay / AlertDialogTitle / AlertDialogDescription / AlertDialogHeader / AlertDialogFooter / AlertDialogClose Same props as the matching Dialog part The Dialog parts under AlertDialog names — Base UI shares the popup, backdrop, title, description and close parts between the two, so the surface is identical. Pass initialFocus to AlertDialogContent (a ref to the Cancel button) to open focus on the safe action.

Props

Name Type Default Description
Dialog (Root) Base UI Dialog.Root props (open, defaultOpen, onOpenChange, modal) — Controls open state. Uncontrolled by default. Records the element that holds focus when the dialog opens (through a DialogTrigger, or your own button flipping a controlled open) and returns focus there on close.
open boolean — Controlled open state. Pair with onOpenChange — for a dialog opened from your own button instead of a DialogTrigger.
defaultOpen boolean false Initial open state when uncontrolled.
onOpenChange (open: boolean, eventDetails) => void — Called when the dialog asks to open or close (a trigger, Esc, an outside click, DialogClose).

Variants

Tokens used

popover, popover-foreground, border, muted-foreground, overlay, overlay-foreground, accent, accent-foreground, ring

Motion

Accessibility

Related

Examples

Fullscreen media

import { Button, Dialog, DialogContent, DialogTrigger } from "@sableui/react"

<Dialog><DialogTrigger render={<Button variant="secondary">View full size</Button>} /><DialogContent size="fullscreen" aria-label="Studio, 2026"><img src={url} alt="Studio, 2026" className="max-h-full max-w-full object-contain p-8" /></DialogContent></Dialog>

Fullscreen gallery

import { Button, Carousel, Dialog, DialogContent, DialogTrigger } from "@sableui/react"

<Dialog><DialogTrigger render={<Button>Open gallery</Button>} /><DialogContent size="fullscreen" aria-label="Gallery"><Carousel loop dots counter label="Gallery" className="w-full max-w-4xl px-8">{images.map((src) => <img key={src} src={src} alt="" className="size-full object-contain" />)}</Carousel></DialogContent></Dialog>

Basic

import { Button, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "@sableui/react"

<Dialog><DialogTrigger render={<Button>Open</Button>} /><DialogContent><DialogHeader><DialogTitle>Plan details</DialogTitle><DialogDescription>Up to 10 seats, billed monthly per seat.</DialogDescription></DialogHeader><DialogFooter><DialogClose render={<Button variant="secondary">Close</Button>} /><DialogClose render={<Button>Upgrade</Button>} /></DialogFooter></DialogContent></Dialog>

Settings form

import { Button, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, Field, Form, Input } from "@sableui/react"

<Dialog><DialogTrigger render={<Button variant="secondary">Rename collection</Button>} /><DialogContent showCloseButton><DialogHeader><DialogTitle>Rename collection</DialogTitle><DialogDescription>Update the display name shown to collectors.</DialogDescription></DialogHeader><Form><Field label="Collection name"><Input defaultValue="Midnight Archive" /></Field><DialogFooter><DialogClose render={<Button variant="secondary">Cancel</Button>} /><Button type="submit">Save changes</Button></DialogFooter></Form></DialogContent></Dialog>

Opened from your own button, keeping a draft

import { Button, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, Field, Textarea } from "@sableui/react"

const [open, setOpen] = useState(false)

<Button variant="secondary" onClick={() => setOpen(true)}>New message</Button>
<Dialog open={open} onOpenChange={setOpen}>
	<DialogContent keepMounted showCloseButton>
		<DialogHeader>
			<DialogTitle>New message</DialogTitle>
			<DialogDescription>Close it any time. Your draft is here when you come back.</DialogDescription>
		</DialogHeader>
		<Field label="Message"><Textarea /></Field>
		<DialogFooter>
			<DialogClose render={<Button variant="secondary">Close</Button>} />
			<Button onClick={() => setOpen(false)}>Send</Button>
		</DialogFooter>
	</DialogContent>
</Dialog>

Destructive confirmation

import { AlertDialog, AlertDialogClose, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, Button } from "@sableui/react"

<AlertDialog><AlertDialogTrigger render={<Button variant="destructive">Delete project</Button>} /><AlertDialogContent><AlertDialogHeader><AlertDialogTitle>Delete project?</AlertDialogTitle><AlertDialogDescription>This removes the project and cannot be undone.</AlertDialogDescription></AlertDialogHeader><AlertDialogFooter><AlertDialogClose render={<Button variant="secondary">Cancel</Button>} /><Button variant="destructive" onClick={deleteProject}>Delete project</Button></AlertDialogFooter></AlertDialogContent></AlertDialog>