docs / core / dialog
Dialog
a window that stops the page until you answer it. for confirmations, short forms, and the last word before something destructive happens.
intensity · recedesrsc · client
provenance
authored in usvalayer
core / primitivesintensity
recedes · safe anywhere, including dense surfacescomposition
confirmations and short forms that block the page until answereddestructive actions pass through it before anything is destroyednot for content that scrolls or pins to an edge. that is Drawernever stack two. a second dialog means the first asked too mucha11y
role="dialog" named by its Title, or aria-label without one · focus moves in on open, Escape closesjest-axedependencies
@base-ui/react · Card from the same packagelive demo · try it out
customize
surfacehow content sits above the scrim
highlightwash, top edge, or glow ring
modalfocus trap, scroll lock, outside-pointer
titlenames the dialog for screen readers
descriptionthe body copy
confirmadd an accent button beside cancel
usage
import { Dialog } from "@usva-ui/react/primitives/dialog";
<Dialog>
<Dialog.Trigger>Open dialog</Dialog.Trigger>
<Dialog.Content>
<Dialog.Title>Confirm action</Dialog.Title>
<Dialog.Description>This can't be undone. Are you sure you want to continue?</Dialog.Description>
<div className="mt-4 flex justify-end gap-2">
<Dialog.Close>Cancel</Dialog.Close>
<button type="button">Confirm</button>
</div>
</Dialog.Content>
</Dialog>props
| prop | type | default | notes |
|---|---|---|---|
| open | boolean | — | controlled open state, on the root. |
| defaultOpen | boolean | false | initial open state when uncontrolled. |
| onOpenChange | (open, eventDetails) => void | — | fires when the open state changes. |
| modal | boolean | "trap-focus" | true | focus trap, scroll lock and outside-pointer behavior in one switch. |
| surface | "elevated" | "flat" | "glass" | "elevated" | how Dialog.Content sits above the scrim. shared with Card and Drawer. |
| highlight | "none" | "wash" | "edge" | "ring" | "none" | accent treatment on Dialog.Content: a radial wash, a top edge hairline, or a glow ring. the same vocabulary as Card. |
| backdropClassName | string | — | extra classes on the scrim, on Dialog.Content. |
get it
bun add @usva-ui/reactusage
import { Dialog } from "@usva-ui/react/primitives/dialog";
<Dialog>
<Dialog.Trigger>Open</Dialog.Trigger>
<Dialog.Content>
<Dialog.Title>Confirm action</Dialog.Title>
<Dialog.Description>This can't be undone.</Dialog.Description>
<Dialog.Close>Cancel</Dialog.Close>
</Dialog.Content>
</Dialog>