Table

RO table on Backlog RO: header, rows with documents, destination, progress, PIC and action, plus loading and empty states.

Open in Figma

Usage

import { Table, TableHeader, TableBody, TableRow, TableHead, TableCell, TableCaption, DestinationCell } from '@pilar-amoda/ui/table';

Rows

Header: height 36, sidebar fill. Row: padding 14/16, gap 16. Hover = accent 60%; data-state="selected" = accent + 3 px primary marker + checked checkbox + primary action; selected hover = accent-hover; focus = inset focus ring.

RO, proyek & dokumenTujuan & tenggatProgresPICAksi
Renovasi Gudang Cikarang
RO-1026-00041 RSVPO-1126-0001Menunggu tinjauan
Teluk Naga WH4 Nov 2026
40% teralokasi6/10 item sisa
RA
Renovasi Kantor Pusat
RO-1026-0007Belum ada dokumen
Jakarta Selatan12 Nov 2026
0% teralokasi12/12 item sisa
DS
Pengadaan Rak Teluk Naga
RO-1026-0009Belum ada dokumen
Teluk Naga WH20 Nov 2026
0% teralokasi8/8 item sisa
RA
'use client';

import { useState } from 'react';

import { Avatar, AvatarFallback } from '@pilar-amoda/ui/avatar';
import { Badge, BadgeDetail, BadgeSeparator } from '@pilar-amoda/ui/badge';
import { Button } from '@pilar-amoda/ui/button';
import { Checkbox } from '@pilar-amoda/ui/checkbox';
import { ArchiveIcon, HashIcon, InboxIcon, ReceiptIcon } from '@pilar-amoda/ui/icons';
import { ProgressCell } from '@pilar-amoda/ui/progress-ring';
import {
  DestinationCell,
  Table,
  TableBody,
  TableCell,
  TableHead,
  TableHeader,
  TableRow,
} from '@pilar-amoda/ui/table';

type RequestOrder = {
  id: string;
  name: string;
  reserved: number;
  po: string | null;
  place: string;
  deadline: string;
  overdue: boolean;
  allocated: number;
  total: number;
  pic: string;
};

const requestOrders: readonly RequestOrder[] = [
  {
    id: 'RO-1026-0004',
    name: 'Renovasi Gudang Cikarang',
    reserved: 1,
    po: 'PO-1126-0001',
    place: 'Teluk Naga WH',
    deadline: '4 Nov 2026',
    overdue: true,
    allocated: 4,
    total: 10,
    pic: 'RA',
  },
  {
    id: 'RO-1026-0007',
    name: 'Renovasi Kantor Pusat',
    reserved: 0,
    po: null,
    place: 'Jakarta Selatan',
    deadline: '12 Nov 2026',
    overdue: false,
    allocated: 0,
    total: 12,
    pic: 'DS',
  },
  {
    id: 'RO-1026-0009',
    name: 'Pengadaan Rak Teluk Naga',
    reserved: 0,
    po: null,
    place: 'Teluk Naga WH',
    deadline: '20 Nov 2026',
    overdue: false,
    allocated: 0,
    total: 8,
    pic: 'RA',
  },
];

/**
 * RO table on Backlog RO. A selected row gets data-state="selected", a checked checkbox and the
 * only primary action.
 */
export const TableBasic = () => {
  const [selected, setSelected] = useState<readonly string[]>(['RO-1026-0004']);

  const allSelected = selected.length === requestOrders.length;
  const toggle = (id: string, checked: boolean) => {
    setSelected((current) => (checked ? [...current, id] : current.filter((item) => item !== id)));
  };

  return (
    <Table>
      <TableHeader>
        <TableRow>
          <TableHead>
            <Checkbox
              aria-label="Pilih semua RO"
              checked={allSelected ? true : selected.length > 0 ? 'indeterminate' : false}
              onCheckedChange={() => {
                setSelected(allSelected ? [] : requestOrders.map((ro) => ro.id));
              }}
              data-testid="chkAll_RoTable"
            />
          </TableHead>
          <TableHead>RO, proyek &amp; dokumen</TableHead>
          <TableHead className="w-44">Tujuan &amp; tenggat</TableHead>
          <TableHead className="w-38">Progres</TableHead>
          <TableHead className="w-7">PIC</TableHead>
          <TableHead className="w-22">
            <span className="sr-only">Aksi</span>
          </TableHead>
        </TableRow>
      </TableHeader>
      <TableBody>
        {requestOrders.map((ro) => {
          const isSelected = selected.includes(ro.id);
          return (
            <TableRow key={ro.id} data-state={isSelected ? 'selected' : undefined}>
              <TableCell>
                <Checkbox
                  aria-label={`Pilih ${ro.name}`}
                  checked={isSelected}
                  onCheckedChange={(checked) => {
                    toggle(ro.id, checked);
                  }}
                  data-testid={`chkRow_${ro.id}`}
                />
              </TableCell>
              <TableCell>
                <div className="flex flex-col gap-1.5">
                  <span className="text-pilar-base font-medium">{ro.name}</span>
                  <div className="flex items-center gap-1.5">
                    <Badge variant="code">
                      <HashIcon size={12} />
                      {ro.id}
                    </Badge>
                    {ro.reserved > 0 && (
                      <Badge variant="outline">
                        <ArchiveIcon size={12} />
                        {ro.reserved} RSV
                      </Badge>
                    )}
                    {ro.po ? (
                      <Badge variant="warning">
                        <ReceiptIcon size={12} />
                        {ro.po}
                        <BadgeSeparator />
                        <BadgeDetail>Menunggu tinjauan</BadgeDetail>
                      </Badge>
                    ) : (
                      ro.reserved === 0 && (
                        <Badge variant="empty">
                          <InboxIcon size={12} />
                          Belum ada dokumen
                        </Badge>
                      )
                    )}
                  </div>
                </div>
              </TableCell>
              <TableCell>
                <DestinationCell place={ro.place} deadline={ro.deadline} overdue={ro.overdue} />
              </TableCell>
              <TableCell>
                <ProgressCell
                  value={Math.round((ro.allocated / ro.total) * 100)}
                  allocated={ro.allocated}
                  total={ro.total}
                />
              </TableCell>
              <TableCell>
                <Avatar>
                  <AvatarFallback>{ro.pic}</AvatarFallback>
                </Avatar>
              </TableCell>
              <TableCell>
                <Button
                  variant={isSelected ? 'default' : 'outline'}
                  data-testid={`btnAllocate_${ro.id}`}
                >
                  Alokasikan
                </Button>
              </TableCell>
            </TableRow>
          );
        })}
      </TableBody>
    </Table>
  );
};

Destination cell

Tujuan & tenggat: 176 wide, warehouse tile 32. overdue shows the deadline in danger.

Jakarta Selatan12 Nov 2026
Teluk Naga WH4 Nov 2026
import { DestinationCell } from '@pilar-amoda/ui/table';

/** "Tujuan & tenggat" cell: an overdue deadline turns danger. */
export const TableDestinationCell = () => (
  <>
    <DestinationCell place="Jakarta Selatan" deadline="12 Nov 2026" />
    <DestinationCell place="Teluk Naga WH" deadline="4 Nov 2026" overdue />
  </>
);

Loading

The header stays visible; 4 skeleton rows on the same grid.

RO, proyek & dokumenTujuan & tenggatProgresPICAksi
import { Checkbox } from '@pilar-amoda/ui/checkbox';
import { Skeleton } from '@pilar-amoda/ui/skeleton';
import {
  Table,
  TableBody,
  TableCell,
  TableHead,
  TableHeader,
  TableRow,
} from '@pilar-amoda/ui/table';

const rows = ['row-1', 'row-2', 'row-3', 'row-4'] as const;

/** State=Loading: the header stays visible; 4 skeleton rows on the same grid as a Table row. */
export const TableLoading = () => (
  <Table aria-busy>
    <TableHeader>
      <TableRow>
        <TableHead>
          <Checkbox aria-label="Pilih semua RO" disabled data-testid="chkAll_RoTableLoading" />
        </TableHead>
        <TableHead>RO, proyek &amp; dokumen</TableHead>
        <TableHead className="w-44">Tujuan &amp; tenggat</TableHead>
        <TableHead className="w-38">Progres</TableHead>
        <TableHead className="w-7">PIC</TableHead>
        <TableHead className="w-22">
          <span className="sr-only">Aksi</span>
        </TableHead>
      </TableRow>
    </TableHeader>
    <TableBody>
      {rows.map((row) => (
        <TableRow key={row} className="hover:bg-transparent">
          <TableCell>
            <Skeleton className="size-4" />
          </TableCell>
          <TableCell>
            <div className="flex flex-col gap-2.5">
              <Skeleton shape="text" />
              <Skeleton shape="text-small" />
            </div>
          </TableCell>
          <TableCell>
            <Skeleton shape="block" className="w-8" />
          </TableCell>
          <TableCell>
            <Skeleton shape="circle" />
          </TableCell>
          <TableCell>
            <Skeleton shape="avatar" />
          </TableCell>
          <TableCell>
            <Skeleton shape="button" />
          </TableCell>
        </TableRow>
      ))}
    </TableBody>
  </Table>
);

Empty, no results, error

The header stays visible; an Empty state spans every column.

RO, proyek & dokumenTujuan & tenggatProgresPICAksi
Tidak ada RO yang cocok
Coba kata kunci lain, atau hapus filter yang sedang aktif.
import { Button } from '@pilar-amoda/ui/button';
import { Checkbox } from '@pilar-amoda/ui/checkbox';
import { EmptyState } from '@pilar-amoda/ui/empty';
import {
  Table,
  TableBody,
  TableCell,
  TableHead,
  TableHeader,
  TableRow,
} from '@pilar-amoda/ui/table';

/** State=No results: the header stays visible and the Empty state spans every column. */
export const TableEmpty = () => (
  <Table>
    <TableHeader>
      <TableRow>
        <TableHead>
          <Checkbox aria-label="Pilih semua RO" disabled data-testid="chkAll_RoTableEmpty" />
        </TableHead>
        <TableHead>RO, proyek &amp; dokumen</TableHead>
        <TableHead className="w-44">Tujuan &amp; tenggat</TableHead>
        <TableHead className="w-38">Progres</TableHead>
        <TableHead className="w-7">PIC</TableHead>
        <TableHead className="w-22">
          <span className="sr-only">Aksi</span>
        </TableHead>
      </TableRow>
    </TableHeader>
    <TableBody>
      <TableRow className="border-b-0 hover:bg-transparent">
        <TableCell colSpan={6} className="p-0 whitespace-normal">
          <EmptyState
            variant="no-results"
            title="Tidak ada RO yang cocok"
            description="Coba kata kunci lain, atau hapus filter yang sedang aktif."
            action={
              <Button variant="outline" data-testid="btnClearFilter_RoTable">
                Hapus filter
              </Button>
            }
          />
        </TableCell>
      </TableRow>
    </TableBody>
  </Table>
);

Do and don't

Do: keep the main action (primary) only on the selected row.
Don't: make every row button primary.