Table

Many records with sortable columns.

$ npx shadcn@latest add https://mahrdesign.faizintifada.com/r/table.json

Sortable, person rows

Grey up/down chevrons on sortable columns; the sorted column shows a dark label and one dark chevron. Cycle none → asc → desc, one column at a time. Rows 64 with avatar + two lines (56 for one line). Hover bg-accent. No zebra, no column borders.

DepartemenTipe
Ayu WulandariHR generalistHR & GATetapRp 11.500.000
Dimas PratamaBackend engineerEngineeringTetapRp 14.000.000
Fajar NugrohoQA engineerEngineeringPercobaanRp 9.800.000
Galih RamadhanStaf gudangOperasionalKontrakRp 6.200.000

Loading and empty

Loading: skeleton rows, same header and height. Empty: one calm row (use EmptyState for a centred block).

NamaDepartemenGaji pokok
NamaDepartemenGaji pokok
Tidak ada karyawan untuk “Budi”.

Pager

Below the card, never inside it, 44 high in every state. "Menampilkan 1–10 dari 48 karyawan" (the range strong) + "Sebelumnya" · "Halaman 1 dari 5" · "Berikutnya" in full words for older users. One page: the count line only, no buttons. Loading: a bar and disabled buttons.

Motion

Motion: wrap the table in TableReveal. While loading, a skeleton card pulses; then 14 skeleton reveal cross-fades the real table in (2px cross-blur, 400 ms). Press "Muat ulang". Row hover uses --duration-quick. Reduced motion: instant swap.

NamaDepartemenGaji pokok
Andi SaputraEngineeringRp 12.500.000
Dewi LestariDesignRp 11.000.000
Dimas PratamaEngineeringRp 13.100.000
Sekar AyuningtyasFinanceRp 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

DoRight-align money with tabular figures"Rp 14.000.000" lines up digit by digit, so people compare amounts at a glance.
Don'tZebra 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.

terminal
bunx --bun shadcn@latest add https://mahrdesign.faizintifada.com/r/table.json

API

import { Table, TableHeader, TableBody, TableRow, TableHead, TableCell, TablePager, … } from "@/components/ui/table"
PropTypeDefaultDescription
TableRow personbooleanfalse64 high (avatar + two lines); otherwise 56.
TableRow data-selectedboolean–Selected row: bg-muted (grey, no hue; same as every chosen list item).
TableHead sortable · sort · onSortboolean · "asc" | "desc" | null · () => void–Use nextSort(dir) for none → asc → desc.
TableHead / TableCell align"left" | "right""left"Right only for numbers.
TableCell moneybooleanfalseRight-aligned, tabular-nums.
TableReveal loading · rows · columnsboolean · number · numberrows 5Wraps <Table>: skeleton card while loading, then 14 skeleton reveal. Preferred loading state.
TableSkeletonRows rows · columnsnumber · number5Skeleton rows inside <TableBody> (pulse only, no reveal).
TableEmpty colSpannumber–One full-width row.
TablePager page · pageCount · total · from · to · unit · loading · onPageChangenumber … · 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.