Table
Many records with sortable columns.
$ npx shadcn@latest add https://mahrdesign.faizintifada.com/r/table.jsonSortable, person rows
| Departemen | Tipe | ||
|---|---|---|---|
| Ayu Wulandari | HR & GA | Tetap | Rp 11.500.000 |
| Dimas Pratama | Engineering | Tetap | Rp 14.000.000 |
| Fajar Nugroho | Engineering | Rp 9.800.000 | |
| Galih Ramadhan | Operasional | Rp 6.200.000 |
Loading and empty
| Nama | Departemen | Gaji pokok |
|---|
| Nama | Departemen | Gaji pokok |
|---|---|---|
| Tidak ada karyawan untuk “Budi”. | ||
Pager
Motion
| Nama | Departemen | Gaji pokok |
|---|---|---|
| Andi Saputra | Engineering | Rp 12.500.000 |
| Dewi Lestari | Design | Rp 11.000.000 |
| Dimas Pratama | Engineering | Rp 13.100.000 |
| Sekar Ayuningtyas | Finance | Rp 8.750.000 |
When to use
- Many records that people compare by column: Karyawan, Riwayat gaji, Permintaan cuti (admin).
- Lists that need sorting or a pager.
When not to use
- Employee screens and short lists (≤ 6 rows) → Card + ListRow.
- One record's details → DetailCard.
- A team overview → PersonCard grid.
Do and don't
Right-align money with tabular figures"Rp 14.000.000" lines up digit by digit, so people compare amounts at a glance.
Zebra stripes, column borders, a pager inside the cardStripes and borders add noise; the pager belongs to the page, below the data it pages.
Installation
Add Table 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 { Table, TableHeader, TableBody, TableRow, TableHead, TableCell, TablePager, … } from "@/components/ui/table"| Prop | Type | Default | Description |
|---|---|---|---|
TableRow person | boolean | false | 64 high (avatar + two lines); otherwise 56. |
TableRow data-selected | boolean | – | Selected row: bg-muted (grey, no hue; same as every chosen list item). |
TableHead sortable · sort · onSort | boolean · "asc" | "desc" | null · () => void | – | Use nextSort(dir) for none → asc → desc. |
TableHead / TableCell align | "left" | "right" | "left" | Right only for numbers. |
TableCell money | boolean | false | Right-aligned, tabular-nums. |
TableReveal loading · rows · columns | boolean · number · number | rows 5 | Wraps <Table>: skeleton card while loading, then 14 skeleton reveal. Preferred loading state. |
TableSkeletonRows rows · columns | number · number | 5 | Skeleton rows inside <TableBody> (pulse only, no reveal). |
TableEmpty colSpan | number | – | One full-width row. |
TablePager page · pageCount · total · from · to · unit · loading · onPageChange | number … · string · boolean · (page) => void | – | A 44 row below the card: "Menampilkan 1–10 dari 48 karyawan" + Sebelumnya · "Halaman 1 dari 5" · Berikutnya. One page: the count line only. loading: a bar + disabled buttons. |