StatTile
One topic, one big figure, one action.
$ npx shadcn@latest add https://mahrdesign.faizintifada.com/r/stat-tile.jsonThe action slot
Sisa cuti tahunan
5
Gajian berikutnya
24 Des
Cuti penting
2hari tersisa dari 3
Slip gaji
Belum ada slip
States
Sisa cuti tahunan
Gajian berikutnya
–
Gagal dimuat.
Slip gaji November
Rp 123.509.137
Motion
Sisa cuti tahunan
5
Slip gaji November
Rp 12.509.137
When to use
- The answer row on Beranda: Sisa cuti, Gajian berikutnya, Slip gaji.
- Balance rows: Cuti tahunan · Cuti penting · Cuti sakit on Cuti saya.
- Admin Ringkasan KPIs (figure + badge + one action link).
When not to use
- More than one figure about the same topic → Card + ListRow (key-value).
- A list of items → Card + ListRow.
- A trend over time → a chart card in Laporan, never a sparkline in a tile.
- More than 4 tiles in one row → cut the data; the 5th figure is not needed.
Do and don't
The figure the user can act on"5" with "Bisa diajukan · 2 menunggu HR" under it: the big number already subtracts requests waiting for HR.
Progress bars, two figures, unequal heights"7 hari tersisa dari 12" plus a bar says the same thing twice. Tiles of different heights break the line of actions.
Installation
Add StatTile 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 { StatTile, StatTileRow } from "@/components/mahr/stat-tile"| Prop | Type | Default | Description |
|---|---|---|---|
module | ModuleId | – | Colours the icon tile only. |
icon · label | NeatIcon · string | – | Label one line, max 24 characters. |
value · unit | string | null · string? | – | Pre-formatted ("5", "Rp 12.509.137"). null = empty → emptyText. |
badge | ReactNode | – | One Badge at the right of the figure (centred on it). Wraps under the figure only when both do not fit. |
meta | ReactNode | – | One muted line under the figure: short text only. |
action | { kind: "button", label, variant?, icon?, onClick? } | { kind: "nav", label, href?, render? } | { kind: "note", text } | – | Always the last line. Max one primary per screen. |
compact | boolean | false | 28 instead of 32 for long money. |
loading · error · onRetry | boolean · boolean · () => void | false | Same height in every state: the skeleton and the error take the box of figure + nav row. Error shows "–" and one row: muted "Gagal dimuat." + a secondary sm "Coba lagi" (the shared failed-load pattern). |
emptyText | string | "–" | Shown when value is null. Say what comes and when ("Belum ada slip"), not "Belum ada data". |
<StatTileRow> | children: 2–4 StatTile | – | Equal widths, gap 16, equal heights. |