Skip to content
Ballpoint

Dialog

A sheet of paper laid over the page: pencilled round, lifted off a hatched shadow, drawn in as it lands.

From shadcn/ui
Built on Base UI Dialog

Installation

pnpm dlx shadcn@latest add @ballpoint/dialog

Usage

tsx
import { Button } from "@/components/ui/button"
import {
  Dialog,
  DialogClose,
  DialogContent,
  DialogDescription,
  DialogFooter,
  DialogHeader,
  DialogTitle,
  DialogTrigger,
} from "@/components/ui/dialog"

<Dialog>
  <DialogTrigger render={<Button variant="outline" />}>Edit profile</DialogTrigger>
  <DialogContent>
    <DialogHeader>
      <DialogTitle>Edit profile</DialogTitle>
      <DialogDescription>Save when you're done.</DialogDescription>
    </DialogHeader>
    <DialogFooter>
      <DialogClose render={<Button />}>Save</DialogClose>
    </DialogFooter>
  </DialogContent>
</Dialog>

Examples

Controlled

Own the open state to close the dialog from code, here when the form is submitted.

Long content

A scrolling region inside a dialog, reachable from the keyboard.

A form

A wider dialog holding two columns of fields and a textarea.

Share a link

A small dialog with a read-only link and a copy button.

Sizes

From a small confirmation to a wide editor.

API reference

DialogContent showCloseButton
default true
boolean

A drawn cross in the top-right corner.

DialogFooter showCloseButton
default false
boolean

Adds an outlined Close button to the footer.

DialogTrigger render
ReactElement

Renders the trigger as your own element, usually a Button.

DialogContent size
default "default"
"sm" | "default" | "lg" | "xl"

How wide it is: 24, 28, 42 or 56rem at most, and never wider than the screen.

seed
string | number

On DialogContent: pins the drawing.

Every other prop goes to Base UI's Dialog.

Pen settings

The drawing also takes draw, roughness, passes, radius, corners, shadow, weight and speed, as props or from the nearest InkProvider. What each one does.