DataTable
An admin list block powered by TanStack Table v9 with server-side pagination, sorting, filtering (text, select, date range), column visibility, row selection, and tree rows in Apple 27 Liquid Glass.
DataTable is a multi-file block (registry:block) bundling the most common admin list layout — Toolbar + Table + Pagination:
- Server-side mode: Pagination, sorting, and filtering are owned by the page (typically synced with URL query params). The table renders the current page and emits user changes through
onChange. - Draft filters: Both column-header filter popovers and the toolbar filter panel edit a local draft; changes are only submitted when clicking Search (clicking Search with unchanged filters triggers
refresh). - Liquid Glass: The table sits inside a
mediumglass panel with pagination controls unified into a shared glass capsule (ButtonGroup). Passingglass={false}switches the entire block (table, toolbar buttons, popovers) to 100% opaque. - Fixed-height scrolling: When placed in a fixed-height flex container, the table fills available space with an independently scrollable body and sticky header; otherwise it grows naturally with content.
Below, default Liquid Glass (glass) and 100% opaque (glass={false}) are shown side by side:
Installation (Shadcn Registry)
npx shadcn@latest add @apple-liquid/data-tableSource files install into components/blocks/data-table/ (following aliases.components in components.json), automatically installing dependent components (table, popover, select, calendar, etc.) and @tanstack/react-table@^9.
Usage
'use client';
import * as React from 'react';
import {
DataTable,
type DataFilterOptions,
type DataTableColumnDef,
type DataTableQuery,
} from '@/components/blocks/data-table';
interface Order {
id: string;
customer: string;
status: 'paid' | 'pending';
}
const columns: DataTableColumnDef<Order>[] = [
{ accessorKey: 'id', header: 'Order ID', size: 120, enableSorting: false },
{ accessorKey: 'customer', header: 'Customer', size: 140, meta: { title: 'Customer' } },
{ accessorKey: 'status', header: 'Status', size: 100, meta: { title: 'Status' } },
];
const filterOptions: DataFilterOptions<Order> = {
customer: { type: 'input', title: 'Customer', placeholder: 'Enter customer name' },
status: {
type: 'select',
title: 'Status',
options: [
{ value: 'paid', label: 'Paid' },
{ value: 'pending', label: 'Pending' },
],
},
};
export function Orders({ data, total, loading, query, onQueryChange }: {
data: Order[];
total: number;
loading: boolean;
query: DataTableQuery;
onQueryChange: (query: DataTableQuery) => void;
}) {
return (
<div className="flex h-[calc(100dvh-8rem)] flex-col">
<DataTable
columns={columns}
data={data}
total={total}
getRowId={(row) => row.id}
loading={loading}
pagination={query.pagination}
sorting={query.sorting}
columnFilters={Object.entries(query.filters).map(([id, value]) => ({ id, value }))}
onChange={onQueryChange}
filterOptions={filterOptions}
/>
</div>
);
}Syncing with URL Search Params
DataTable is router- and protocol-agnostic: it communicates strictly through pagination / sorting / columnFilters and onChange(query). In your app pages, serialize and deserialize DataTableQuery using your preferred router or state library (such as useSearchParams, nuqs, or route loaders).
Tree Table
Pass getSubRows to enable hierarchical tree rows (expanded by default, preserving user-collapsed rows across refreshes). Pass showPageOptions={false} for unpaginated tables to show only the total count.
Responsive Behavior
Desktop (macOS 27, ≥ 768px) | Mobile (iOS 27, < 768px) | |
|---|---|---|
| Filter / Sort / Columns | Anchored glass popover / menu | Bottom Liquid Glass drawer (Popover / DropdownMenu / Select adapt automatically) |
| Date Range | Dual-month calendar | Single-month calendar |
| Toolbar Buttons | Icon + label | Icon only (with aria-label) |
| First / Last Page Buttons | Visible (≥ 1024px) | Hidden (Previous / Next only) |
Props API
| Prop | Type | Default | Description |
|---|---|---|---|
columns | DataTableColumnDef<TData>[] | — | Column definitions; meta.title labels the Columns menu, size controls width proportion |
data | TData[] | — | Rows for the current page |
total | number | — | Total row count across all pages |
getRowId | (row) => string | — | Unique row ID used to preserve selection across pages |
loading | boolean | false | Displays a loading overlay and spins the Refresh icon |
pagination / sorting / columnFilters | TanStack state | Page 1 · 10 rows / none / none | Controlled active query state owned by the page |
onChange | (query: DataTableQuery) => void | — | Fired on pagination, sorting, or clicking Search (resets pageIndex to 0 when filters change) |
rowSelection / onRowSelectionChange | RowSelectionState | — | Pass onRowSelectionChange to enable cross-page row selection |
filterOptions | DataFilterOptions<TData> | — | Map of column ID to filter config (input / select / dateRange) |
extraBars | ReactNode | — | Extra actions on the right side of the toolbar (e.g. "Create") |
refresh | () => void | — | Shows the Refresh button; also invoked when clicking Search with unchanged filters |
getSubRows | (row) => TData[] | undefined | — | Accessor for nested tree rows |
showPageOptions | boolean | true | Whether to render page-size selector and pagination buttons |
pageSizeOptions | number[] | [10, 20, 30, 50] | Available page sizes |
locale | LiquidGlassLocaleInput | Global locale | UI language of this instance; overrides <LiquidGlassProvider locale> |
messages | Partial<DataTableMessages> | Built-in text | Text overrides, deep-merged over the built-in text and the global messages.dataTable |
glass | boolean | true | Liquid Glass material for the table and toolbar; false renders 100% opaque |
className | string | — | Root container class name |
DataFilterOption
| Prop | Type | Description |
|---|---|---|
type | 'input' | 'select' | 'dateRange' | Fuzzy text / single select / date range ({ from?: Date; to?: Date }) |
title | ReactNode | Filter field label |
description | string | Helper text under the popover title (defaults to filter hint by type) |
placeholder | string | Placeholder for input / select controls |
options | { label; value }[] | Choices for select filters |
Upload
Apple Liquid Glass file upload component with a refined default dropzone, drag-and-drop, file validation, upload progress, and full custom trigger support.
File Preview
Preview almost any file in the browser — images, video, PDF, Office, archives, e-mail, CAD, 3D models, maps and code — with a Liquid Glass toolbar and an all-viewer dialog. Every format library loads on demand.