Skip to Content
Liquid Glass UI
Blocks

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 medium glass panel with pagination controls unified into a shared glass capsule (ButtonGroup). Passing glass={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:

apple-liquid-ui/preview/data-table-demo
MacBook · 16:10

Installation (Shadcn Registry)

npx shadcn@latest add @apple-liquid/data-table

Source 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.

apple-liquid-ui/preview/data-table-tree
MacBook · 16:10

Responsive Behavior

Desktop (macOS 27, ≥ 768px)Mobile (iOS 27, < 768px)
Filter / Sort / ColumnsAnchored glass popover / menuBottom Liquid Glass drawer (Popover / DropdownMenu / Select adapt automatically)
Date RangeDual-month calendarSingle-month calendar
Toolbar ButtonsIcon + labelIcon only (with aria-label)
First / Last Page ButtonsVisible (≥ 1024px)Hidden (Previous / Next only)

Props API

PropTypeDefaultDescription
columnsDataTableColumnDef<TData>[]—Column definitions; meta.title labels the Columns menu, size controls width proportion
dataTData[]—Rows for the current page
totalnumber—Total row count across all pages
getRowId(row) => string—Unique row ID used to preserve selection across pages
loadingbooleanfalseDisplays a loading overlay and spins the Refresh icon
pagination / sorting / columnFiltersTanStack statePage 1 · 10 rows / none / noneControlled 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 / onRowSelectionChangeRowSelectionState—Pass onRowSelectionChange to enable cross-page row selection
filterOptionsDataFilterOptions<TData>—Map of column ID to filter config (input / select / dateRange)
extraBarsReactNode—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
showPageOptionsbooleantrueWhether to render page-size selector and pagination buttons
pageSizeOptionsnumber[][10, 20, 30, 50]Available page sizes
localeLiquidGlassLocaleInputGlobal localeUI language of this instance; overrides <LiquidGlassProvider locale>
messagesPartial<DataTableMessages>Built-in textText overrides, deep-merged over the built-in text and the global messages.dataTable
glassbooleantrueLiquid Glass material for the table and toolbar; false renders 100% opaque
classNamestring—Root container class name

DataFilterOption

PropTypeDescription
type'input' | 'select' | 'dateRange'Fuzzy text / single select / date range ({ from?: Date; to?: Date })
titleReactNodeFilter field label
descriptionstringHelper text under the popover title (defaults to filter hint by type)
placeholderstringPlaceholder for input / select controls
options{ label; value }[]Choices for select filters

On this page