Sheet
A floating 480 side panel for forms and records.
$ npx shadcn@latest add https://mahrdesign.faizintifada.com/r/sheet.jsonForm sheet
Open state (inline)
Ajukan cuti
Slip November · Dimas
Gaji bersih diterimaRp 12.509.137
When to use
- A form with 2 or more fields: Ajukan cuti, Tambah karyawan, Minta perubahan ke HR.
- "Ubah" on a DetailCard: the sheet shows only that card's fields (Ubah kontak darurat).
- Reading one record without leaving the list: Slip November, Perbaiki baris.
When not to use
- One confirmation or one field → Dialog.
- A flow with steps or a full table (Impor dari Excel) → its own page with a stepper.
- A short list of actions → DropdownMenu.
- Never open a sheet on top of a sheet. The only Dialog over a sheet is its own discard question.
Do and don't
Only the card's own fields"Ubah" on Kontak darurat opens Nama, Hubungan, Telepon: nothing else. The title is verb + the card name.
Edge-to-edge drawer or a third footer buttonAlways the 12 inset and radius 16. No primary on the left, no third button, no width other than 480.
Installation
Add Sheet 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 { Sheet, SheetTrigger, SheetContent, SheetHeader, SheetBody, SheetFooter, SheetClose } from "@/components/ui/sheet"| Prop | Type | Default | Description |
|---|---|---|---|
open · onOpenChange · defaultOpen | boolean · (open, details) => void · boolean | – | Base UI Root props. |
dirty | boolean | false | true → closing (×, Esc, backdrop, Batal) asks "Buang perubahan?" first, in a centred destructive Dialog over the sheet (Kembali / Buang). Esc or Kembali closes only the question. On open, focus goes to the first field in SheetBody. |
discard | { title?, description?, keep?, discard? } | Buang perubahan? · Kembali · Buang | Other words for the discard Dialog of one form, e.g. Tambah karyawan: "Buang data yang sudah diisi?" · "Data Putri Ramadhani belum disimpan. Jika ditutup sekarang, semua isian hilang." · "Lanjut isi" · "Ya, buang data". The safe button keeps focus. |
defaultAsking | boolean | false | Preview and tests only: start with the discard question shown. |
SheetHeader title · description | ReactNode | – | Title = verb + object. Description one line. |
SheetBody | div | – | Scrolls; fields gap 20; the scroll hint appears by itself. |
SheetFooter | div | – | Two buttons that hug their labels, aligned right. form: Batal + primary. detail: Tutup + one secondary. |