Dialog

A centred confirm or one-field question.

$ npx shadcn@latest add https://mahrdesign.faizintifada.com/r/dialog.json

Destructive

No close on a backdrop click. Cancel = "Kembali" because the confirm verb starts with "Batalkan". Solid red only here. Motion: transitions.dev modal: scale .96 → 1 + fade, open 250 / close 150, ease-smooth-out; backdrop fades on the same clocks.

Confirm

A non-destructive question; the confirm is the primary. Backdrop click closes.

Open state (inline)

Width 460, padding 24, radius 16, shadow-modal. Right: kind="form" with one field.

Batalkan cuti 30–31 Des?

Permintaan ditarik dari HR. Saldo cuti Anda tidak berubah.

Tolak cuti Citra?

Citra melihat alasan ini di riwayat cutinya.

When to use

  • Confirm a destructive or hard-to-undo action: "Batalkan cuti 30–31 Des?".
  • Confirm a step with side effects: "Tandai gaji Desember sudah dibayar?".
  • Ask for exactly one value before an action: "Alasan penolakan".

When not to use

  • 2 or more fields → Sheet (480 side panel).
  • A result the user cannot see otherwise → Toast.
  • A lasting status on the page → Callout or Badge.
  • A list of actions → DropdownMenu.

Which one?

How many fields does the user fill in?├─ 2 or more → Sheet├─ 1 → <Dialog kind="form">└─ 0   Is the action destructive or hard to undo?   ├─ Yes → <Dialog kind="destructive">  confirm = variant="destructive"   └─ No  → <Dialog kind="confirm">      confirm = variant="primary"

Do and don't

DoName the thing in the title"Batalkan cuti 30–31 Des?": the user reads what is affected without the body.
Don't"Apakah Anda yakin?" with Ya / TidakIt says nothing. Use the verb on the confirm button: "Batalkan permintaan", "Tolak cuti".

Installation

Add Dialog with the shadcn CLI (your project needs a components.json and the MaHR theme: https://mahrdesign.faizintifada.com/r/theme.json), or copy the files by hand.

terminal
bunx --bun shadcn@latest add https://mahrdesign.faizintifada.com/r/dialog.json

API

import { Dialog, DialogTrigger, DialogContent, … } from "@/components/ui/dialog"
PropTypeDefaultDescription
kind (on Dialog only)"confirm" | "destructive" | "form""confirm"destructive = alertdialog role, backdrop does not close.
open · onOpenChangeboolean · (open, details) => void–Controlled (Base UI Root).
DialogTrigger renderReactElement–The Button that opens it.
DialogClose renderReactElement–Footer buttons close the dialog.
DialogTitle · DialogDescriptionReactNode–Title 18/24 (the card-title role); body 16/24 muted.
Focus on open (DialogContent initialFocus)auto by kind–form → the first field; confirm → the confirm button; destructive → the safe button (Batal / Kembali), so Enter never confirms a delete. Pass initialFocus to override.
DialogFooterdiv–Two buttons that hug their labels, aligned right: cancel left, confirm right.