Getting Started
Installation
Install shadcn-table into a Base UI, Radix UI or React Aria shadcn/ui project with one shadcn CLI command, or hand the setup to your coding agent.
Prerequisites
A shadcn/ui project on the Base UI, Radix UI or React Aria base, with React 19.2 or later and Tailwind CSS 4.3 or later. React Aria is supported since 0.5.0.
No project yet? Create one. Pick your base with the tabs: Base UI, Radix UI or React Aria. A React Aria project has an aria-* style in components.json (aria-nova is the style the React Aria copy is built on).
pnpm dlx shadcn@latest init --base baseCreated with shadcn create
A project made with shadcn create needs no extra setup. The table renders through the shadcn/ui parts the project installs, so it follows the project's base, theme, base color, radius, menu accent and fonts.
- Icon library: pick the project's icon library in the install command below. Each one installs its own edition of the table's
icons.tsand only that icon package. - RTL: on a right-to-left page, set
columnResizeDirection: 'rtl'on the table so column resizing follows the pointer.
Installation
Install
One command adds the table, the shadcn/ui components it uses and its npm packages. Pick your icon library: Lucide installs shadcn-table.json, Tabler shadcn-table-tabler.json, and the others their own shadcn-table-<library>.json. Turn on Short form to install by name, @shadcn-table/<item>, once the namespace is in components.json; registering it is optional.
pnpm dlx shadcn@latest add https://www.shadcn-table.com/r/base/shadcn-table.jsonVerify
You should now see these files in your project:
components/ui/
├── shadcn-table/ ← new: the whole table library, yours to edit
│ ├── ShadcnTable.tsx
│ ├── index.ts
│ ├── types.ts
│ ├── components/
│ ├── features/
│ ├── hooks/
│ └── shared/
├── button.tsx ← shadcn/ui components the table needs, added automatically
├── dialog.tsx
└── ...Your global stylesheet is unchanged. The table's animations ship inside its components as a <style> tag that React hoists into <head>. Under a strict Content Security Policy, allow it with a nonce or style-src 'unsafe-inline'.
Known issue on React Aria
shadcn's aria-nova label part starts with an unused import * as React from "react".
Vite's React template type-checks with noUnusedLocals, so a fresh
shadcn init --template vite --base aria project reports TS6133 in
components/ui/label.tsx. The file is your project's own after shadcn add: delete that
import line, or set "noUnusedLocals": false in tsconfig.app.json. Not a shadcn-table
defect.
Use it
Define columns, then pass them with your data to useShadcnTable.
import { useMemo } from 'react';
import {
ShadcnTable,
useShadcnTable,
type ST_ColumnDef,
} from '@/components/ui/shadcn-table';
type Person = { name: string; age: number };
const data: Person[] = [
{ name: 'John', age: 30 },
{ name: 'Sara', age: 25 },
];
export function PeopleTable() {
const columns = useMemo<ST_ColumnDef<Person>[]>(
() => [
{ accessorKey: 'name', header: 'Name' },
{ accessorKey: 'age', header: 'Age' },
],
[],
);
const table = useShadcnTable({ columns, data });
return <ShadcnTable table={table} />;
}Updating
Run the install command again with --overwrite. It replaces every file in components/ui/shadcn-table/, so commit or back up your local edits first.
pnpm dlx shadcn@latest add https://www.shadcn-table.com/r/base/shadcn-table.json --overwriteTo switch icon library, pick the new one above and run the command with --overwrite. It replaces icons.ts and adds the new icon package; the previous icon package stays in package.json, remove it by hand when nothing else uses it.
Uninstall
- Delete
components/ui/shadcn-table/. - Remove the npm packages if nothing else uses them:
@tanstack/react-table,@tanstack/react-store,@tanstack/react-virtual,@tanstack/match-sorter-utils,highlight-words, and on React Ariareact-aria-components(the shadcn/ui React Aria components use it too).
Nothing else to undo: the install never touches your global CSS.
The shadcn/ui components stay. Other parts of your app may use them.
Introduction
shadcn-table is a data table for shadcn/ui built on TanStack Table: one command copies the source, one hook turns sorting, filtering and more on.
Usage
Build a first shadcn-table: import ShadcnTable and useShadcnTable, define stable data and column definitions, then turn features on with options.