Skip to content
Ballpoint

Alert Dialog

A note that needs an answer before you go on, laid over the page with its choices.

From shadcn/ui
Built on Base UI Alert Dialog

Installation

pnpm dlx shadcn@latest add @ballpoint/alert-dialog

Usage

tsx
import {
  AlertDialog,
  AlertDialogAction,
  AlertDialogCancel,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogFooter,
  AlertDialogHeader,
  AlertDialogTitle,
  AlertDialogTrigger,
} from "@/components/ui/alert-dialog"
import { Button } from "@/components/ui/button"

<AlertDialog>
  <AlertDialogTrigger render={<Button variant="destructive" />}>Delete</AlertDialogTrigger>
  <AlertDialogContent>
    <AlertDialogHeader>
      <AlertDialogTitle>Delete this notebook?</AlertDialogTitle>
      <AlertDialogDescription>This can't be undone.</AlertDialogDescription>
    </AlertDialogHeader>
    <AlertDialogFooter>
      <AlertDialogCancel>Keep it</AlertDialogCancel>
      <AlertDialogAction variant="destructive">Delete</AlertDialogAction>
    </AlertDialogFooter>
  </AlertDialogContent>
</AlertDialog>

Examples

Confirming an action

The action runs only when confirmed; cancelling leaves things as they were.

48 pages in this notebook.

Type to confirm

The destructive action stays disabled until the notebook's name is typed.

Small, with an icon

size="sm" with an AlertDialogMedia icon and two short buttons.

API reference

AlertDialogContent size
default "default"
"default" | "sm"

Small centres everything and puts the two buttons side by side.

AlertDialogMedia
component

An icon in a ring drawn round it, beside the title.

AlertDialogAction / AlertDialogCancel
Button props

The answer, and the way out. Cancel closes the dialog and is outlined by default.

seed
string | number

On AlertDialogContent: pins the drawing.

Every other prop goes to Base UI's Alert 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.