RepositoryTypeScript
Monabbir-Ahmmad

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

51sao
5fork
0issue
0lượt xem

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.

Release CI GitHub Stars License

View Documentation

shadcn-react-table demo: sorting, search, column drag and resize, row selection, cell editing, grouping, 100,000 virtualized rows, shadcn styles and right-to-left languages

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
  • slotProps for 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.json

The registry JSON is generated by pnpm --filter shadcn-react-table-web registry:build (also runs automatically on build) into apps/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:

DependencyNeeded for
@tanstack/match-sorter-utilsfuzzy global search
@tanstack/react-virtualrow / column virtualization
@dnd-kit/core @dnd-kit/sortable @dnd-kit/utilitiescolumn / row drag-and-drop
date-fnsdate / date-range filters
lucide-reactdefault 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 TooltipProvider inside 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 selectionenableRowSelection, enableMultiRowSelection
Filter row visible by defaultinitialState: { showColumnFilters: true }
Per-column filter UIcolumnDef.meta.filterVariant (text/select/multi-select/autocomplete/range/date/time/…)
Global fuzzy searchon by default; enableGlobalFilter: false to hide
Column drag / pin / resizeenableColumnOrdering, enableColumnPinning, enableColumnResizing
Row drag / pin / numbersenableRowOrdering + onRowOrderChange, enableRowPinning, enableRowNumbers
Grouping + aggregationenableGrouping + column footer/aggregationFn
Sticky header / footeron by default; scrolls within a bounded surface (max-h) or virtualized list
Detail panel / treerenderDetailPanel / getSubRows
Inline editingenableEditing, editDisplayMode (cell/row/table/modal) + onEditingCellSave/onEditingRowSave/onCreatingRowSave
Row / cell actionsrenderRowActions, renderCellActionMenuItems, enableClickToCopy
VirtualizationenableRowVirtualization, enableColumnVirtualization (give the surface a bounded height)
Row/cell clicksonRowClick / onCellClick (+ double-click)
Custom icons / i18nicons, localization
Animationson by default; enableAnimations: false to turn off
Server-side datamanualPagination / 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 host
  • packages/shadcn-react-table — the @monabbir/shadcn-react-table data-table (the product; consumed as source via transpilePackages, no build step)
  • packages/ui — @workspace/ui, the shared shadcn primitives + lib/utils + globals.css the 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.

Dự án tương tự

Khám phá các dự án và mô hình AI khác có sự tương đồng.

RepositoryTypeScript
shadcn-ui/ui

Composable, accessible components with thoughtful defaults. Build your own component library with code you can customize, extend, and make your own.

129.8k
Dec 2, 2026
RepositoryTypeScript
trpc/trpc

🧙‍♀️ Move Fast and Break Nothing. End-to-end typesafe APIs made easy.

40.9k
Dec 1, 2026
RepositoryTypeScript
cosscom/ui

coss.com/ui is the official design system of Cal.com

11.3k
Nov 26, 2026
RepositoryTypeScript
ncdai/chanhdai.com

A pixel-perfect dev portfolio and shadcn registry.

2.4k
Nov 30, 2026
RepositoryTypeScript
openstatusHQ/data-table-filters

React data tables for shadcn/ui: faceted filters, sorting, infinite scroll. Filtering, faceted counts and cursor pagination can run in SQL with Drizzle.

2.3k
Nov 9, 2026
RepositoryTypeScript
1771-Technologies/lytenyte

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.

1.0k
Aug 15, 2026
RepositoryTypeScript
Semkoo/niko-table-registry

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.

72
Nov 30, 2026
RepositoryJavaScript
vercel/next.js

The React Framework

143.9k
Dec 1, 2026
RepositoryJavaScript
vercel/next.js

The React Framework

143.9k
Dec 1, 2026