Haedong
011

Dialog

Overlay

No decision yet

Customize

Footer

Code

const [open, setOpen] = useState(false);

<Button onClick={() => setOpen(true)}>Open</Button>
<Dialog open={open} onOpenChange={setOpen}>
  <DialogHeader>
    <DialogTitle>Delete draft?</DialogTitle>
    <DialogClose />
  </DialogHeader>
  <DialogDescription>This cannot be undone.</DialogDescription>
  <DialogFooter>
    <Button variant="ghost" onClick={() => setOpen(false)}>Cancel</Button>
    <Button variant="solid" onClick={confirm}>Delete</Button>
  </DialogFooter>
</Dialog>

Install

npx shadcn@latest add https://components.haedong.dev/r/dialog.json

Props

Dialog props below. DialogHeader is a baseline row; DialogTitle and DialogDescription label and describe the dialog; DialogFooter right-aligns actions; DialogClose is a muted text button (children = label, default "Close"). Renders through a portal into <body>.

PropTypeDescription
openbooleanControlled visibility.
onOpenChange(open: boolean) => voidCalled with false on Esc, backdrop click or DialogClose.
aria-labelstringLabels the dialog when there is no DialogTitle.
classNamestringExtra classes for the panel (default max-w-md, 12px from the viewport edges).