Monabbir-Ahmmad/shadcn-react-table
A shadcn/ui data table with Material React Table feature parity, built on TanStack Table v9 and Tailwind v4 — installed as source you own via the shadcn registry
shadcn-react-table
A fully featured shadcn/ui implementation of TanStack React Table V9, with Material React Table (MRT V3) feature parity — shipped as a shadcn registry block, not a library.
View Documentation
About
Quickly create high-quality React data tables that look and feel like the rest of your shadcn/ui project.
Built with shadcn/ui, TanStack Table V9, and Tailwind CSS V4. The API and feature set are modeled on Material React Table V3 — all of MRT V3's feature guides are implemented.
Because it ships as a shadcn registry block, the source is copied into your project: no library to version-match, nothing hidden, every file yours to edit.
Learn More
Features
All features can be enabled or disabled per table.
- Sorting (multi-sort, per-column config, custom
sortFns) - Column filtering with filter modes (contains, between, empty, …,
plus your own
filterFns) and variants (text,select,multi-select,autocomplete,checkbox,range,range-slider,date,date-range,datetime,datetime-range,time,time-range) + faceted values - Advanced filter panel (compound and/or rules)
- Fuzzy global search (
@tanstack/match-sorter-utils) with search modes - Filter match highlighting, kept in custom cells via
renderedCellValue - Column ordering (drag & drop), pinning (freeze columns), resizing, visibility
- Row selection (multi / single, shift-click ranges), select-all, alert banner
- Row ordering (drag & drop, also between tables), row pinning, row numbers
- Grouping + aggregation (drop zone, group menu, aggregated cells, footers)
- Expansion: detail panels and tree data (
getSubRows) - Inline editing (
cell/row/table/modal) + row creation - Row actions, cell action menus, click-to-copy
- Row and column virtualization (
@tanstack/react-virtual) - Sticky header / footer, density toggle, full-screen toggle
- Pagination (default or numbered pages) + keyboard grid navigation
- Localization (full string table) and custom icons (any icon library)
- 38 languages, each an optional registry item
- Server-side / manual mode (
manualPagination/manualSorting/manualFiltering) - Animations (Web Animations API, no dependency): rows glide on sort,
filter, group and pin, detail panels open smoothly, the toolbar moves;
off under reduced motion or with
enableAnimations: false -
slotPropsfor every part, composition parts, and the full TanStack v9 API - Theming via shadcn tokens only — inherits your style, base color, and dark mode
- Radix UI and Base UI flavors supported from the same registry URL
No built-in export — like MRT, exporting is a few lines against the table state model; the export guide has a copy-paste recipe.
Getting Started
Installation
In any shadcn/ui project (Tailwind v4, CSS variables on — the default):
pnpm dlx shadcn@latest add https://monabbir-ahmmad.github.io/shadcn-react-table/r/data-table.json
That copies the data-table files into your @/components/ui/data-table/
(rewriting import aliases to match your project), installs the npm
dependencies, and injects the --highlight theme token (falls back to
--accent if dropped). The shadcn primitives it relies on (button, table,
select, …) are pulled from the shadcn registry in your own configured style
and base color — any you already have are reused, not overwritten. A current
shadcn CLI (4.x, the one with init -b radix|base) adapts the source to your
project's flavor at install time. No manual wiring.
Trying it from this repo: run the demo (
pnpm dev) and point the CLI at the locally served descriptor:npx shadcn@latest add http://localhost:3000/r/data-table.jsonThe registry JSON is generated by
pnpm --filter shadcn-react-table-web registry:build(also runs automatically onbuild) intoapps/web/public/r/.
Prefer to install manually?
First make sure the shadcn primitives the table uses are in your project (this
also pulls their own deps like react-day-picker, cmdk, and your flavor's
headless library — radix-ui or @base-ui/react):
npx shadcn@latest add badge button calendar checkbox command context-menu dialog dropdown-menu input input-group label popover select skeleton slider table tooltip
Copy packages/shadcn-react-table/src/components/data-table/ into your @/components/ui/data-table/,
then add the table's own npm deps:
pnpm add @tanstack/react-table@^9 @tanstack/match-sorter-utils@^9 @tanstack/react-virtual @dnd-kit/core @dnd-kit/sortable @dnd-kit/utilities date-fns lucide-react
Only @tanstack/react-table is strictly required; the rest are per-feature:
| Dependency | Needed for |
|---|---|
@tanstack/match-sorter-utils | fuzzy global search |
@tanstack/react-virtual | row / column virtualization |
@dnd-kit/core @dnd-kit/sortable @dnd-kit/utilities | column / row drag-and-drop |
date-fns | date / date-range filters |
lucide-react | default icons (override via the icons prop) |
Tailwind v4 + the shadcn token theme are required. Finally, add the
--highlight tokens to your globals.css (the registry install injects these
for you; they fall back to --accent if omitted):
@theme inline {
--color-highlight: var(--highlight, var(--accent));
--color-highlight-foreground: var(
--highlight-foreground,
var(--accent-foreground)
);
}
:root {
--highlight: oklch(0.905 0.158 96.5);
--highlight-foreground: oklch(0.35 0.07 72);
}
.dark {
--highlight: oklch(0.85 0.16 96.5);
--highlight-foreground: oklch(0.26 0.05 72);
}
Tooltips are wrapped in a local
TooltipProviderinside the table, so you do not need a global provider.
Usage
Define your data type and columns, hand them to useDataTable, and render
<DataTable>. Per-column behaviour (filter variant, alignment, edit variant,
aggregation, click-to-copy, …) is configured via columnDef.meta.
"use client"
import * as React from "react"
// after `shadcn add` it lands here; inside this monorepo it's @monabbir/shadcn-react-table/components/data-table
import {
DataTable,
useDataTable,
type DataTableColumnDef,
} from "@/components/ui/data-table"
type Payment = {
id: string
customer: string
email: string
status: "paid" | "pending" | "failed"
amount: number
}
const columns: DataTableColumnDef<Payment>[] = [
{ accessorKey: "customer", header: "Customer" },
{
accessorKey: "email",
header: "Email",
meta: { enableClickToCopy: true },
},
{
accessorKey: "status",
header: "Status",
meta: {
filterVariant: "multi-select",
filterSelectOptions: [
{ label: "Paid", value: "paid" },
{ label: "Pending", value: "pending" },
{ label: "Failed", value: "failed" },
],
},
},
{
accessorKey: "amount",
header: "Amount",
meta: { align: "right", filterVariant: "range-slider" },
cell: ({ getValue }) =>
new Intl.NumberFormat("en-US", {
style: "currency",
currency: "USD",
}).format(getValue<number>()),
},
]
export function PaymentsTable({ data }: { data: Payment[] }) {
// Stable references are required — memoize data/columns (or hold them in state).
const cols = React.useMemo(() => columns, [])
const table = useDataTable({
data,
columns: cols,
getRowId: (row) => row.id, // recommended whenever selection/expansion is on
enableRowSelection: true,
enableColumnPinning: true,
initialState: { showColumnFilters: true },
})
return <DataTable table={table} />
}
useDataTable extends the full TanStack TableOptions, so state +
onChange, manual* server-side flags, row models, getRowId, etc. all pass
straight through. The table's own methods live on table (table.setDensity,
table.beginRowEdit, …) and its UI state (density, full screen, filter row,
editing, …) in table.getState(), controlled like any TanStack state with
initialState / state + on…Change.
Feature flags (the common ones)
Pass these to useDataTable:
| Want… | Option(s) |
|---|---|
| Row selection | enableRowSelection, enableMultiRowSelection |
| Filter row visible by default | initialState: { showColumnFilters: true } |
| Per-column filter UI | columnDef.meta.filterVariant (text/select/multi-select/autocomplete/range/date/time/…) |
| Global fuzzy search | on by default; enableGlobalFilter: false to hide |
| Column drag / pin / resize | enableColumnOrdering, enableColumnPinning, enableColumnResizing |
| Row drag / pin / numbers | enableRowOrdering + onRowOrderChange, enableRowPinning, enableRowNumbers |
| Grouping + aggregation | enableGrouping + column footer/aggregationFn |
| Sticky header / footer | on by default; scrolls within a bounded surface (max-h) or virtualized list |
| Detail panel / tree | renderDetailPanel / getSubRows |
| Inline editing | enableEditing, editDisplayMode (cell/row/table/modal) + onEditingCellSave/onEditingRowSave/onCreatingRowSave |
| Row / cell actions | renderRowActions, renderCellActionMenuItems, enableClickToCopy |
| Virtualization | enableRowVirtualization, enableColumnVirtualization (give the surface a bounded height) |
| Row/cell clicks | onRowClick / onCellClick (+ double-click) |
| Custom icons / i18n | icons, localization |
| Animations | on by default; enableAnimations: false to turn off |
| Server-side data | manualPagination / manualSorting / manualFiltering + rowCount + controlled state |
The component-level data-table README
documents the full option set, columnDef.meta fields, server-side mode, and
stability requirements.
Versioning & Changelog
The block follows semantic versioning: a major version
for breaking changes, a minor for new features, a patch for fixes. The registry
block carries its version in meta.version (from
packages/shadcn-react-table/package.json). Every version is documented in the
changelog and published as a
GitHub release;
see the updating guide
for pulling a new version into your project. 1.0.0 is the first stable
release (TanStack Table v9, one table API); the updating guide lists every
rename from 0.x with a before/after.
Development
Turborepo + pnpm workspaces (apps/*, packages/*):
apps/web— Next.js 16 docs site / examples browser / registry hostpackages/shadcn-react-table— the@monabbir/shadcn-react-tabledata-table (the product; consumed as source viatranspilePackages, no build step)packages/ui—@workspace/ui, the shared shadcn primitives +lib/utils+globals.cssthe data-table depends on (also consumed as source)packages/eslint-config,packages/typescript-config— shared config
pnpm dev # run the demo app
pnpm build # build all workspaces
pnpm lint # eslint
pnpm typecheck # tsc --noEmit
pnpm format # prettier --write
pnpm test # unit tests (Vitest + Testing Library)
pnpm test:browser # browser tests (Vitest browser mode, Chromium)
To add a shadcn/ui primitive, run from the repo root (components land in
packages/ui/src/components, the @workspace/ui package):
pnpm dlx shadcn@latest add <component> -c apps/web
Import shared primitives with import { Foo } from "@workspace/ui/components/foo".
Acknowledgments
The API surface, option names, and feature set are openly modeled on Material React Table by Kevin Van Cott — years of API design iteration this project gratefully stands on. The translations are adapted from its locales (MIT License). Powering everything underneath: TanStack Table and shadcn/ui.
Similar Projects
Discover other similar projects and AI models.
Composable, accessible components with thoughtful defaults. Build your own component library with code you can customize, extend, and make your own.
React data tables for shadcn/ui: faceted filters, sorting, infinite scroll. Filtering, faceted counts and cursor pagination can run in SQL with Drizzle.
LyteNyte Grid monorepo: Build powerful data tables with a lightning-fast, zero-dependency React data grid (~40 KB). Headless or pre-styled. Declarative API. 150+ enterprise-grade features. Supported by 1771 Technologies.
Composable, accessible React data tables for shadcn/ui, built on TanStack Table. Sorting, filters, editable grid and virtualization for 500,000+ rows, in code you own.