Blackwork
Scroll to top

Dialog

A modal for a short task that should block the rest of the page.

Dialog

When to use

  • Confirm a destructive action
  • Edit a small set of fields without leaving the page
  • Show required information the user must acknowledge

Use Sheet if the content should stay attached to one edge, or if the user may need the page behind it as reference.

Usage

The trigger should be a real button. Prefer asChild on DialogTrigger.

Usage

Structure

PartRole
DialogOpen state
DialogTriggerOpens the dialog
DialogContentPortal, overlay, and panel
DialogHeader / DialogTitle / DialogDescriptionAccessible heading
DialogFooterActions
DialogCloseExplicit close

DialogTitle is required for accessibility. DialogContent already renders a corner close button.

API Reference

The trigger accepts asChild. DialogContent already includes a close button.

PropTypeDefaultDescription
asChildbooleanfalseOn DialogTrigger and DialogClose. Merge props onto a real button child.
openbooleanControlled open state on Dialog.
defaultOpenbooleanUncontrolled initial open state on Dialog.
onOpenChange(open: boolean) => voidCalled when the dialog opens or closes.

Notes

  • The asChild child must be a button. Do not wrap Button in a div.
  • Keep dialog copy short. Long forms belong in a page or a sheet.