DataTable
Empty results use a full-width icon and message instead of an empty horizontally scrolling table. Loading, populated rows, and pagination remain independent.
Smart table molecule built on Table + Pagination. Pass plain objects and column definitions — sorting, pagination, alignment, empty states, and footers come for free.
Playground
Live preview
| Status | |||
|---|---|---|---|
Midnight Vault | EU-West | Live | 240 PH |
Neon Harbor | US-East | Review | 360 PH |
Static Ridge | AP-South | Draft | 285 PH |
Ghost Circuit | EU-North | Live | 1280 PH |
Ember Crossing | EU-West | Review | 300 PH |
| Total rewards | 47895 PH | ||
Examples
Long content — wallet addresses and URLs
Full synthetic addresses, URLs, unbroken references, and long headers must wrap within their columns. Balance, network, checkboxes, and sort icons must remain readable. Narrow preview scrolls inside the table.
| Balance | Network | |||
|---|---|---|---|---|
| 0x1234567890abcdef1234567890abcdef12345678 | https://example.com/transactions/0xabcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789 | 1,234.56 PH | Polygon | |
| 123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmn | A long transaction description with ordinary spaces that should wrap across multiple lines without covering the balance or network. | 98.00 PH | Solana | |
| 0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef | unbroken-reference-0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef | 0.01 PH | Test network |
Examples
Compact mobile rows — placed and hidden columns
Activity: Funds addedUSDC deposit on Polygon Date: Nov 9, 14:48 Amount: +$50.00 Status: Completed |
Activity: Mission reserveA long mission title that wraps within the available space Date: Nov 8, 09:10 Amount: −$40.00 Status: Processing |
| Activity | Date | Amount | Status | Reference |
|---|---|---|---|---|
| Funds addedUSDC deposit on Polygon | Nov 9, 14:48 | +$50.00 | Completed | 0x1234567890abcdef |
| Mission reserveA long mission title that wraps within the available space | Nov 8, 09:10 | −$40.00 | Processing | 0xabcdef1234567890 |
Activity and date share the left column; amount and status share the right. The reference stays available on desktop and is hidden here.
Persistent backoffice pagination — one page and empty
| Status | |||
|---|---|---|---|
Midnight Vault | EU-West | Live | 240 PH |
No delivery receipts
| Status | |||
|---|---|---|---|
Midnight Vault | EU-West | Live | 240 PH |
Empty state
No hunts found. Create one to get started.
Code
import { Badge, DataTable, IconButton } from "@npolyhunter/ui";
import type { DataTableColumn } from "@npolyhunter/ui";
// Pass plain objects + column definitions. Sorting and pagination work
// out of the box; sortable columns toggle asc → desc → none on click.
// Column props: key, header, sortable, align ("left" | "center" | "right"),
// width ("120px", "20%"…), render(row), className, mobile. Columns without a width
// share the remaining space — pin the small ones and leave the main one auto.
// Cells and headers wrap long text (including unbroken addresses/URLs).
// Custom flex/grid renderers need min-w-0 on shrinking text children.
// With mobileLayout, mobile: { column: "start" | "end", row: 1 } places
// a column in a compact row; mobile: "hidden" omits it only on mobile.
const columns: Array<DataTableColumn<Hunt>> = [
// Auto width — absorbs the remaining space.
{ key: "name", header: "Hunt", sortable: true },
// Fixed widths.
{ key: "region", header: "Region", sortable: true, width: "110px" },
{ key: "status", header: "Status", width: "110px",
render: (row) => <Badge variant={...}>{row.status}</Badge> },
{ key: "reward", header: "Reward", align: "right",
sortable: true, width: "120px" },
];
// Client-side: sorts and paginates the data itself.
<DataTable
data={hunts}
columns={columns}
mobileLayout
pageSize={5}
density="comfortable" // or "compact"
hoverable
emptyMessage="No hunts found."
/>;
// Controlled (server-side) mode: pass sort/page + onSortChange/onPageChange
// and totalItems — the table stops slicing/sorting and just renders what
// your API returns. Use the loading prop to show an indeterminate progress
// bar under the header while fetching (current rows stay visible).
<DataTable
data={pageFromApi}
columns={columns}
sort={sort}
onSortChange={setSort}
page={page}
onPageChange={setPage}
pageSize={10}
totalItems={totalFromApi}
loading={isFetching}
/>;
// Keep controls visible for single-page and empty admin tables.
<DataTable data={pageFromApi} columns={columns} pageSize={20} totalItems={totalFromApi} showPagination />;
// Row selection: a checkbox column with a select-all header (toggles the
// current page). Controlled via selectedKeys + onSelectionChange — the
// callback receives both the key list and the full selected rows.
<DataTable
data={hunts}
columns={columns}
selectable
selectedKeys={selected}
onSelectionChange={(keys, rows) => setSelected(keys)}
/>;
// Totals / footer: any row content, rendered in the footer's surface style.
<DataTable
data={hunts}
columns={columns}
footer={
<TableRow>
<TableCell colSpan={3}>Total rewards</TableCell>
<TableCell align="right">{total} PH</TableCell>
</TableRow>
}
/>;Code
import { Badge, DataTable, IconButton } from "@npolyhunter/ui";
import type { DataTableColumn } from "@npolyhunter/ui";
// Pass plain objects + column definitions. Sorting and pagination work
// out of the box; sortable columns toggle asc → desc → none on click.
// Column props: key, header, sortable, align ("left" | "center" | "right"),
// width ("120px", "20%"…), render(row), className, mobile. Columns without a width
// share the remaining space — pin the small ones and leave the main one auto.
// Cells and headers wrap long text (including unbroken addresses/URLs).
// Custom flex/grid renderers need min-w-0 on shrinking text children.
// With mobileLayout, mobile: { column: "start" | "end", row: 1 } places
// a column in a compact row; mobile: "hidden" omits it only on mobile.
const columns: Array<DataTableColumn<Hunt>> = [
// Auto width — absorbs the remaining space.
{ key: "name", header: "Hunt", sortable: true },
// Fixed widths.
{ key: "region", header: "Region", sortable: true, width: "110px" },
{ key: "status", header: "Status", width: "110px",
render: (row) => <Badge variant={...}>{row.status}</Badge> },
{ key: "reward", header: "Reward", align: "right",
sortable: true, width: "120px" },
];
// Client-side: sorts and paginates the data itself.
<DataTable
data={hunts}
columns={columns}
mobileLayout
pageSize={5}
density="comfortable" // or "compact"
hoverable
emptyMessage="No hunts found."
/>;
// Controlled (server-side) mode: pass sort/page + onSortChange/onPageChange
// and totalItems — the table stops slicing/sorting and just renders what
// your API returns. Use the loading prop to show an indeterminate progress
// bar under the header while fetching (current rows stay visible).
<DataTable
data={pageFromApi}
columns={columns}
sort={sort}
onSortChange={setSort}
page={page}
onPageChange={setPage}
pageSize={10}
totalItems={totalFromApi}
loading={isFetching}
/>;
// Keep controls visible for single-page and empty admin tables.
<DataTable data={pageFromApi} columns={columns} pageSize={20} totalItems={totalFromApi} showPagination />;
// Row selection: a checkbox column with a select-all header (toggles the
// current page). Controlled via selectedKeys + onSelectionChange — the
// callback receives both the key list and the full selected rows.
<DataTable
data={hunts}
columns={columns}
selectable
selectedKeys={selected}
onSelectionChange={(keys, rows) => setSelected(keys)}
/>;
// Totals / footer: any row content, rendered in the footer's surface style.
<DataTable
data={hunts}
columns={columns}
footer={
<TableRow>
<TableCell colSpan={3}>Total rewards</TableCell>
<TableCell align="right">{total} PH</TableCell>
</TableRow>
}
/>;Used in
Includes use through shared UI components.
AppBack Office
