DetailCard
Key-value rows with one access mode.
$ npx shadcn@latest add https://mahrdesign.faizintifada.com/r/detail-card.jsonAccess modes
Pekerjaan
DepartemenEngineering
JabatanBackend engineer
AtasanIndra Wijaya
Kontak darurat
NamaSari Pratiwi
HubunganIstri
Telepon0812 7730 1945
Data pribadi
Telepon0813 2045 7781
AlamatJl. Tebet Barat Dalam IV No. 12, RT 05/RW 02, Jakarta Selatan
Golongan darah–
Rekening & pajak
RekeningBCA •••• 4521
NIK3174 •••• •••• 0007
Status PTKPK/0
Admin record: no tile, trailing eye, footer, readonly
Gaji
Gaji pokokRp ••••••
RekeningBCA •••• 7890
NPWPTerdaftar · TK/0
Keluar
Tanggal keluar30 Sep 2026
AlasanMengundurkan diri
Gaji terakhirSep 2026
Pending request and loading
Rekening & pajak
Permintaan perubahan dikirim 17 Des. Data lama tetap dipakai sampai HR mengubahnya.
RekeningBCA •••• 4521
NPWP09.254.•••.•-014.000
Kontak darurat
Nama
Hubungan
Telepon
When to use
- Profil saya: Pekerjaan, Kontak darurat, Data pribadi, Rekening & pajak (2×2 grid).
- Karyawan Detail (admin): Pekerjaan, Cuti, Data pribadi, Gaji.
- Pengaturan sections (Profil perusahaan, Jadwal gaji).
When not to use
- Values that change every month (saldo, gaji bersih) → StatTile.
- A list of many records → Table or Card + ListRow.
- Editing in place inside the card → never; "Ubah" opens a Sheet with only this card's fields.
- The person's identity at the top of a page → ProfileCard header.
Do and don't
Group by who may change itTelepon and Alamat sit in "Data pribadi" (Ubah); Rekening, NIK, NPWP in "Rekening & pajak" (Minta perubahan). One card = one permission.
A pencil on every row, or two header actionsPer-row edit icons make 20 tiny targets for older users. "Ubah" + "Minta perubahan" in one header means the card mixes permissions: split it.
Installation
Add DetailCard 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 { DetailCard } from "@/components/mahr/detail-card"| Prop | Type | Default | Description |
|---|---|---|---|
title · description | string · string? | – | description = one muted line under the title ("Dibayar tiap tanggal 25."). |
icon · module | NeatIcon? · ModuleId | – · "karyawan" | Optional tile; module sets its colours. Admin record pages have no tile. |
access | "editable" | "request" | "locked" | "readonly" | "locked" | Comes from the user's permission, not from the page. readonly = no action (archived record). |
rows | { label; value: ReactNode | null; trailing?; emphasis?; alignValue?: "left" | "right" }[] | – | null → "–". Max 6 rows; more → split the card. trailing = ONE IconButton; the row stays 56. emphasis = a total row (bg-background, 600). |
labelWidth · footer | number · ReactNode | 160 · – | Label column in px (120 in a 400 wide card). footer = one CardFooterLink, pinned to the bottom. |
onEdit · onRequest | () => void | – | editable → onEdit (opens Sheet). request → onRequest. |
pendingRequest · loading | { sentAt, href?, render? } | null · boolean | null · false | Pending shows the inline warning Callout and swaps the action to "Lihat permintaan". |
error · onRetry | boolean · () => void | false | Failed load: the header stays; the rows' space shows "Gagal dimuat." + secondary "Coba lagi" at the same height (shared LoadError pattern). |