Dialog

A modal window that overlays the page to display focused content or capture user input.

Installation

pnpm dlx stera-ui add dialog

Usage

import {
  Dialog,
  DialogTrigger,
  DialogPopup,
  DialogHeader,
  DialogTitle,
  DialogDescription,
  DialogContent,
  DialogFooter,
  DialogClose,
} from "@/components/ui/dialog"
<Dialog>
  <DialogTrigger render={<Button variant="outline">Open</Button>} />
  <DialogPopup>
    <DialogHeader>
      <DialogTitle>Dialog Title</DialogTitle>
      <DialogDescription>Dialog description.</DialogDescription>
    </DialogHeader>
    <DialogContent>
      {/* body content */}
    </DialogContent>
    <DialogFooter showCloseButton>
      <Button>Save</Button>
    </DialogFooter>
  </DialogPopup>
</Dialog>

Confirmation Dialog

Use DialogClose with a custom button to create cancel/confirm action pairs.

Scrollable Content

Set scroll="content" on DialogPopup and scroll on DialogContent to let the body scroll while the header and footer remain sticky.

API Reference

DialogPopup

PropTypeDefault
scrollfalse | "content"false
showCloseButtonbooleantrue
initialFocusbooleantrue

DialogFooter

PropTypeDefault
showCloseButtonbooleanfalse

DialogTrigger

PropTypeDescription
renderReactElementRender prop for the trigger element

DialogClose

PropTypeDescription
renderReactElementRender prop for the close element