Dialog
A centred confirm or one-field question.
$ npx shadcn@latest add https://mahrdesign.faizintifada.com/r/dialog.jsonDestructive
Confirm
Open state (inline)
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?
Do and don't
Name the thing in the title"Batalkan cuti 30–31 Des?": the user reads what is affected without the body.
"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.
API
import { Dialog, DialogTrigger, DialogContent, … } from "@/components/ui/dialog"| Prop | Type | Default | Description |
|---|---|---|---|
kind (on Dialog only) | "confirm" | "destructive" | "form" | "confirm" | destructive = alertdialog role, backdrop does not close. |
open · onOpenChange | boolean · (open, details) => void | – | Controlled (Base UI Root). |
DialogTrigger render | ReactElement | – | The Button that opens it. |
DialogClose render | ReactElement | – | Footer buttons close the dialog. |
DialogTitle · DialogDescription | ReactNode | – | 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. |
DialogFooter | div | – | Two buttons that hug their labels, aligned right: cancel left, confirm right. |