Skip to content
Niko Table

Installation

Install DataTable from the niko-table registry with the shadcn CLI—TanStack Table v9, optional pagination, filters, virtualization, and more.

Before installing the DataTable component, make sure you have:

  1. A React project (Next.js, Vite, etc.)

  2. Shadcn UI set up in your project (Installation Guide) — both the Radix (new-york) and Base UI (base-nova) generations are supported

  3. TailwindCSS configured

  4. TypeScript (recommended)

  5. TanStack Table v9 — this registry targets @tanstack/react-table@^9. The CLI pins that range when you install registry items; for a manual add use:

    pnpm add @tanstack/react-table@^9

Works with both shadcn generations. The registry installs cleanly whether your components.json style is the classic Radix generation ("new-york") or the newer Base UI generation ("base-nova", the current shadcn init default). The source is written to typecheck against both: the shadcn CLI adapts Radix idioms (asChild → render) during install, and DataTable callbacks and props are dual-generation safe. If you hit a type error after install, make sure you’re on a recent shadcn CLI and re-add the block with --overwrite.

To use the @niko-table/ namespace with the shadcn CLI, you must first register it in your project’s components.json. Add the registries field:

components.json
{
"$schema": "https://ui.shadcn.com/schema.json",
// ... your existing config (style, tailwind, aliases, etc.)
"registries": {
"@niko-table": "https://niko-table.com/r/{name}.json"
}
}

Tip: If you prefer not to modify components.json, you can install any component directly via URL instead – see the URL-based commands in each section below.

Install in two steps (or all at once):

  1. Install the owner once — @niko-table/data-table copies DataTableRoot, chrome, and (transitively) data-table-core + data-table-ui into your project.
  2. Add features one by one — run the CLI for each feature you need (pagination, search filter, DnD, etc.). Each add-on depends on data-table-core, so the CLI installs or reuses the shared floor without pulling Root or overwriting table.tsx.

Now install the owner:

pnpm dlx shadcn@latest add @niko-table/data-table

Requires the @niko-table registry in your components.json. See the Installation Guide for setup. Or install directly via URL:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table.json"

This installs the full table owner (data-table + data-table-core + data-table-ui). That includes lib/data-table-features.ts — TanStack Table v9’s feature registration that DataTableRoot passes to useTable. Trim it after install the same way you omit registry items you never mount. See Table Features.

For pagination, filters, DnD, virtualization, aside, and other features, add the optional blocks below (one by one) or use Install Everything. If you own the TanStack instance yourself and only need controls + structure, skip data-table and install the control items directly — see Components.

Want every registry item at once? List them explicitly — the shadcn CLI does not support wildcards like @niko-table/**. Prefer installing only what you need (see Components); reach for this when you want the full set.

pnpm dlx shadcn@latest add @niko-table/data-table @niko-table/data-table-virtualized @niko-table/data-table-pagination @niko-table/data-table-search-filter @niko-table/data-table-sort-menu @niko-table/data-table-view-menu @niko-table/data-table-view-dnd-menu @niko-table/data-table-clear-filter @niko-table/data-table-filter-menu @niko-table/data-table-faceted-filter @niko-table/data-table-inline-filter @niko-table/data-table-slider-filter @niko-table/data-table-date-filter @niko-table/data-table-export-button @niko-table/data-table-aside @niko-table/data-table-selection-bar @niko-table/data-table-column-sort @niko-table/data-table-column-hide @niko-table/data-table-column-pin @niko-table/data-table-column-group @niko-table/data-table-column-resize @niko-table/data-table-column-auto-fit @niko-table/data-table-column-sizing-persistence @niko-table/data-table-column-faceted-filter @niko-table/data-table-column-slider-filter @niko-table/data-table-column-date-filter @niko-table/data-table-row-dnd @niko-table/data-table-column-dnd @niko-table/data-table-virtualized-row-dnd @niko-table/data-table-virtualized-column-dnd @niko-table/data-table-grid @niko-table/data-table-grid-changes

You can also browse / filter the registry with:

npx shadcn@latest search @niko-table

If you prefer not to configure the registry, pass full URLs instead:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table.json" "https://niko-table.com/r/data-table-virtualized.json" "https://niko-table.com/r/data-table-pagination.json" "https://niko-table.com/r/data-table-search-filter.json" "https://niko-table.com/r/data-table-sort-menu.json" "https://niko-table.com/r/data-table-view-menu.json" "https://niko-table.com/r/data-table-view-dnd-menu.json" "https://niko-table.com/r/data-table-clear-filter.json" "https://niko-table.com/r/data-table-filter-menu.json" "https://niko-table.com/r/data-table-faceted-filter.json" "https://niko-table.com/r/data-table-inline-filter.json" "https://niko-table.com/r/data-table-slider-filter.json" "https://niko-table.com/r/data-table-date-filter.json" "https://niko-table.com/r/data-table-export-button.json" "https://niko-table.com/r/data-table-aside.json" "https://niko-table.com/r/data-table-selection-bar.json" "https://niko-table.com/r/data-table-column-sort.json" "https://niko-table.com/r/data-table-column-hide.json" "https://niko-table.com/r/data-table-column-pin.json" "https://niko-table.com/r/data-table-column-group.json" "https://niko-table.com/r/data-table-column-resize.json" "https://niko-table.com/r/data-table-column-auto-fit.json" "https://niko-table.com/r/data-table-column-sizing-persistence.json" "https://niko-table.com/r/data-table-column-faceted-filter.json" "https://niko-table.com/r/data-table-column-slider-filter.json" "https://niko-table.com/r/data-table-column-date-filter.json" "https://niko-table.com/r/data-table-row-dnd.json" "https://niko-table.com/r/data-table-column-dnd.json" "https://niko-table.com/r/data-table-virtualized-row-dnd.json" "https://niko-table.com/r/data-table-virtualized-column-dnd.json" "https://niko-table.com/r/data-table-grid.json" "https://niko-table.com/r/data-table-grid-changes.json"

Or install only the components you need. Each component can be added individually:

DataTablePagination:

pnpm dlx shadcn@latest add @niko-table/data-table-pagination

Requires the @niko-table registry in your components.json. See the Installation Guide for setup. Or install directly via URL:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table-pagination.json"

DataTableSearchFilter:

pnpm dlx shadcn@latest add @niko-table/data-table-search-filter

Requires the @niko-table registry in your components.json. See the Installation Guide for setup. Or install directly via URL:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table-search-filter.json"

DataTableSortMenu:

pnpm dlx shadcn@latest add @niko-table/data-table-sort-menu

Requires the @niko-table registry in your components.json. See the Installation Guide for setup. Or install directly via URL:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table-sort-menu.json"

DataTableViewMenu:

pnpm dlx shadcn@latest add @niko-table/data-table-view-menu

Requires the @niko-table registry in your components.json. See the Installation Guide for setup. Or install directly via URL:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table-view-menu.json"

DataTableViewDndMenu (column visibility + drag-to-reorder):

pnpm dlx shadcn@latest add @niko-table/data-table-view-dnd-menu

Requires the @niko-table registry in your components.json. See the Installation Guide for setup. Or install directly via URL:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table-view-dnd-menu.json"

DataTableClearFilter:

pnpm dlx shadcn@latest add @niko-table/data-table-clear-filter

Requires the @niko-table registry in your components.json. See the Installation Guide for setup. Or install directly via URL:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table-clear-filter.json"

DataTableExportButton:

pnpm dlx shadcn@latest add @niko-table/data-table-export-button

Requires the @niko-table registry in your components.json. See the Installation Guide for setup. Or install directly via URL:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table-export-button.json"

DataTableFilterMenu:

pnpm dlx shadcn@latest add @niko-table/data-table-filter-menu

Requires the @niko-table registry in your components.json. See the Installation Guide for setup. Or install directly via URL:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table-filter-menu.json"

DataTableFacetedFilter:

pnpm dlx shadcn@latest add @niko-table/data-table-faceted-filter

Requires the @niko-table registry in your components.json. See the Installation Guide for setup. Or install directly via URL:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table-faceted-filter.json"

DataTableInlineFilter:

pnpm dlx shadcn@latest add @niko-table/data-table-inline-filter

Requires the @niko-table registry in your components.json. See the Installation Guide for setup. Or install directly via URL:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table-inline-filter.json"

DataTableSliderFilter:

pnpm dlx shadcn@latest add @niko-table/data-table-slider-filter

Requires the @niko-table registry in your components.json. See the Installation Guide for setup. Or install directly via URL:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table-slider-filter.json"

DataTableDateFilter:

pnpm dlx shadcn@latest add @niko-table/data-table-date-filter

Requires the @niko-table registry in your components.json. See the Installation Guide for setup. Or install directly via URL:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table-date-filter.json"

DataTableColumnSort:

pnpm dlx shadcn@latest add @niko-table/data-table-column-sort

Requires the @niko-table registry in your components.json. See the Installation Guide for setup. Or install directly via URL:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table-column-sort.json"

DataTableColumnHide:

pnpm dlx shadcn@latest add @niko-table/data-table-column-hide

Requires the @niko-table registry in your components.json. See the Installation Guide for setup. Or install directly via URL:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table-column-hide.json"

DataTableColumnPin:

pnpm dlx shadcn@latest add @niko-table/data-table-column-pin

Requires the @niko-table registry in your components.json. See the Installation Guide for setup. Or install directly via URL:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table-column-pin.json"

DataTableColumnGroup:

pnpm dlx shadcn@latest add @niko-table/data-table-column-group

Requires the @niko-table registry in your components.json. See the Installation Guide for setup. Or install directly via URL:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table-column-group.json"

DataTableColumnResize:

pnpm dlx shadcn@latest add @niko-table/data-table-column-resize

Requires the @niko-table registry in your components.json. See the Installation Guide for setup. Or install directly via URL:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table-column-resize.json"

DataTableColumnAutoFit:

pnpm dlx shadcn@latest add @niko-table/data-table-column-auto-fit

Requires the @niko-table registry in your components.json. See the Installation Guide for setup. Or install directly via URL:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table-column-auto-fit.json"

useColumnSizingPersistence (persist column widths):

pnpm dlx shadcn@latest add @niko-table/data-table-column-sizing-persistence

Requires the @niko-table registry in your components.json. See the Installation Guide for setup. Or install directly via URL:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table-column-sizing-persistence.json"

DataTableColumnFacetedFilter:

pnpm dlx shadcn@latest add @niko-table/data-table-column-faceted-filter

Requires the @niko-table registry in your components.json. See the Installation Guide for setup. Or install directly via URL:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table-column-faceted-filter.json"

DataTableColumnSliderFilter:

pnpm dlx shadcn@latest add @niko-table/data-table-column-slider-filter

Requires the @niko-table registry in your components.json. See the Installation Guide for setup. Or install directly via URL:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table-column-slider-filter.json"

DataTableColumnDateFilter:

pnpm dlx shadcn@latest add @niko-table/data-table-column-date-filter

Requires the @niko-table registry in your components.json. See the Installation Guide for setup. Or install directly via URL:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table-column-date-filter.json"

DataTableVirtualized:

pnpm dlx shadcn@latest add @niko-table/data-table-virtualized

Requires the @niko-table registry in your components.json. See the Installation Guide for setup. Or install directly via URL:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table-virtualized.json"

DataGrid (editable spreadsheet):

Turns the virtualized table into a keyboard-navigable, clipboard-aware editable grid. See the Data Grid docs.

pnpm dlx shadcn@latest add @niko-table/data-table-grid

Requires the @niko-table registry in your components.json. See the Installation Guide for setup. Or install directly via URL:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table-grid.json"

Optional change-set tracking for saves (useGridChanges):

pnpm dlx shadcn@latest add @niko-table/data-table-grid-changes

Requires the @niko-table registry in your components.json. See the Installation Guide for setup. Or install directly via URL:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table-grid-changes.json"

DataTableAside:

pnpm dlx shadcn@latest add @niko-table/data-table-aside

Requires the @niko-table registry in your components.json. See the Installation Guide for setup. Or install directly via URL:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table-aside.json"

DataTableSelectionBar:

pnpm dlx shadcn@latest add @niko-table/data-table-selection-bar

Requires the @niko-table registry in your components.json. See the Installation Guide for setup. Or install directly via URL:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table-selection-bar.json"

DataTableRowDnd:

pnpm dlx shadcn@latest add @niko-table/data-table-row-dnd

Requires the @niko-table registry in your components.json. See the Installation Guide for setup. Or install directly via URL:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table-row-dnd.json"

DataTableColumnDnd:

pnpm dlx shadcn@latest add @niko-table/data-table-column-dnd

Requires the @niko-table registry in your components.json. See the Installation Guide for setup. Or install directly via URL:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table-column-dnd.json"

DataTableVirtualizedRowDnd (needs virtualized + row-dnd):

pnpm dlx shadcn@latest add @niko-table/data-table-virtualized-row-dnd

Requires the @niko-table registry in your components.json. See the Installation Guide for setup. Or install directly via URL:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table-virtualized-row-dnd.json"

DataTableVirtualizedColumnDnd (needs virtualized + column-dnd):

pnpm dlx shadcn@latest add @niko-table/data-table-virtualized-column-dnd

Requires the @niko-table registry in your components.json. See the Installation Guide for setup. Or install directly via URL:

pnpm dlx shadcn@latest add "https://niko-table.com/r/data-table-virtualized-column-dnd.json"

Row DnD should not be combined with sorting or filtering. Column DnD is safe with any feature. Row and column packages are axis-isolated — installing one does not copy the other.

The DataTable components use a two-layer architecture for maximum flexibility:

  • Components (data-table-*.tsx in /components folder) - Context-aware wrapper components that use useDataTable() hook to automatically get the table from DataTableRoot context. These eliminate prop drilling and are the recommended way to use components:
    • DataTableSearchFilter, DataTableFilterMenu, DataTableSortMenu, DataTablePagination, etc.
  • Filters (table-*.tsx in /filters folder) - Core implementation components that accept a table prop directly and read from the TanStack Table instance (like table.state, table.setGlobalFilter(), etc.). These can be used standalone:
    • TableSearchFilter, TableFilterMenu, TableSortMenu, etc.

Why this architecture?

  • Use DataTable* components from their direct paths (e.g. @/components/niko-table/components/data-table-pagination) when you want context-based, zero-config usage
  • Use Table* components from filters (e.g. @/components/niko-table/filters/table-pagination) when you want to build custom components or manage the table instance yourself
  • All filter components use TanStack Table hooks directly, giving you full control

Learn more in the Introduction.

@niko-table/data-table pulls @niko-table/data-table-ui, which installs a custom components/ui/table.tsx that extends the default Shadcn table with:

  • A TableComponent export (used internally by DataTable — plain <table> without the scroll wrapper)
  • data-slot attributes on all elements
  • A scroll container with tabIndex={0} so keyboard users can focus and arrow-scroll it (WCAG 2.1.1)

À-la-carte controls that only depend on data-table-core do not install this file, so a deliberately customized table.tsx will not be overwritten. Install @niko-table/data-table-ui yourself when you want our primitive, or keep yours if it exports TableComponent.

Note: Our table.tsx is 100% backward compatible with existing Shadcn tables. If you already have a table.tsx and install data-table / data-table-ui, the CLI will prompt before overwriting.

If your project uses a non-standard UI component path (e.g., packages/ui/src/components/ instead of src/components/ui/), the shadcn CLI may place table.tsx in the wrong location. This is a known upstream shadcn CLI quirk with registry:ui path resolution.

Workaround: After installing, check that table.tsx landed in the correct directory. If it was placed in a nested ui/ folder, move it to your actual UI components path and ensure it exports TableComponent:

// Your existing table.tsx — add this function and export
function TableComponent({
className,
...props
}: React.ComponentProps<"table">) {
return (
<table
data-slot="table"
className={cn("w-full caption-bottom text-sm", className)}
{...props}
/>
)
}
// Add TableComponent to your existing exports
export {
TableComponent,
Table,
TableHeader,
// ... your other exports
}

Prefer to copy and paste all components manually? Check out our Manual Installation Guide page where you can copy all the component files at once.

Let’s build your first table. We’ll start with a simple table and progressively add features.

  1. Start by defining your data

    The following data represents a list of users with their names and emails.

    components/example-table.tsx
    type User = {
    id: string
    name: string
    email: string
    status: "active" | "inactive"
    }
    const data: User[] = [
    { id: "1", name: "John Doe", email: "john@example.com", status: "active" },
    { id: "2", name: "Jane Smith", email: "jane@example.com", status: "active" },
    { id: "3", name: "Bob Johnson", email: "bob@example.com", status: "inactive" },
    ]
  2. Define your columns

    Columns define how your data is displayed in the table.

    components/example-table.tsx
    import type { DataTableColumnDef } from "@/components/niko-table/types"
    const columns: DataTableColumnDef<User>[] = [
    {
    accessorKey: "name",
    header: "Name",
    },
    {
    accessorKey: "email",
    header: "Email",
    },
    {
    accessorKey: "status",
    header: "Status",
    cell: ({ row }) => (
    <span
    className={
    row.original.status === "active"
    ? "text-success"
    : "text-muted-foreground"
    }
    >
    {row.original.status}
    </span>
    ),
    },
    ]
  3. Build your table

    You can now build your table using DataTable components.

    components/example-table.tsx
    import { DataTableRoot } from "@/components/niko-table/core/data-table-root"
    import { DataTable } from "@/components/niko-table/core/data-table"
    import {
    DataTableHeader,
    DataTableBody,
    } from "@/components/niko-table/core/data-table-structure"
    export function ExampleTable() {
    return (
    <DataTableRoot data={data} columns={columns}>
    <DataTable>
    <DataTableHeader />
    <DataTableBody />
    </DataTable>
    </DataTableRoot>
    )
    }

Different examples require different dependencies. Here’s what you need for each:

  • @tanstack/react-table@^9
  • Shadcn: table
  • @tanstack/react-table@^9
  • Shadcn: table, button, dropdown-menu
  • @tanstack/react-table@^9
  • Shadcn: table, button, input, dropdown-menu
  • @tanstack/react-table@^9
  • Shadcn: table, button, input, dropdown-menu, popover, command, checkbox, select
  • @tanstack/react-table@^9
  • Shadcn: table, button, checkbox, dropdown-menu
  • @tanstack/react-table@^9
  • Shadcn: table, button, input, dropdown-menu
  • @tanstack/react-table@^9
  • Shadcn: table, button, input, dropdown-menu
  • @tanstack/react-table@^9
  • Shadcn: table, button, input, dropdown-menu
  • Registry: @niko-table/data-table-column-group
  • @tanstack/react-table@^9
  • @tanstack/react-virtual
  • Shadcn: table, button, input, dropdown-menu, scroll-area
  • @tanstack/react-table@^9
  • Shadcn: table, button, input, dropdown-menu, popover, command, checkbox, select, scroll-area, separator, skeleton, tooltip
  • Inline Filters: Included in DataTable components (no additional dependencies)
  • Sortable Rows (optional): @niko-table/data-table-row-dnd — installs its @dnd-kit dependencies automatically (built on DiceUI Sortable patterns)
  • @tanstack/react-table@^9
  • nuqs (nuqs.dev) - Type-safe search params state manager for URL state management
  • Shadcn: All components from Advanced Table
  • Inline Filters: Included in DataTable components (no additional dependencies)
  • Sortable Rows (optional): @niko-table/data-table-row-dnd — installs its @dnd-kit dependencies automatically (built on DiceUI Sortable patterns)

Some advanced features may require additional dependencies:

For URL state persistence in tables, install nuqs:

npm install nuqs

nuqs provides type-safe search params state management, perfect for syncing table filters, pagination, and sorting with the URL.

For drag-and-drop row reordering, install the registry block — it brings its @dnd-kit dependencies with it:

pnpm dlx shadcn@latest add @niko-table/data-table-row-dnd

See the Row DnD Table example for usage. (The sortable primitives follow DiceUI Sortable patterns.)

After installation, your project structure should look like:

src/
├── components/
│ ├── ui/ # Shadcn UI components
│ └── niko-table/ # DataTable components
│ ├── core/
│ ├── types/
│ ├── hooks/
│ ├── components/
│ ├── filters/
│ ├── config/
│ └── lib/
└── lib/
└── utils.ts

Create a simple test to verify everything is working:

import { DataTableRoot } from "@/components/niko-table/core/data-table-root"
import { DataTable } from "@/components/niko-table/core/data-table"
import {
DataTableHeader,
DataTableBody,
} from "@/components/niko-table/core/data-table-structure"
const columns = [
{ accessorKey: "name", header: "Name" },
{ accessorKey: "email", header: "Email" },
]
const data = [
{ id: "1", name: "John Doe", email: "john@example.com" },
{ id: "2", name: "Jane Smith", email: "jane@example.com" },
]
export function TestTable() {
return (
<DataTableRoot data={data} columns={columns}>
<DataTable>
<DataTableHeader />
<DataTableBody />
</DataTable>
</DataTableRoot>
)
}

Now that you have the DataTable installed, check out the examples: