Skip to content

Installation

How to install and set up the DataTable component in your project.

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)
  3. TailwindCSS configured
  4. TypeScript (recommended)

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 use TanStack Table hooks (like table.getState(), 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.

The DataTable registry automatically installs a custom components/ui/table.tsx that extends the default Shadcn table with:

  • A TableComponent export (used internally by DataTable)
  • data-slot attributes on all elements
  • A container div for overflow handling

Note: This is 100% backward compatible — your existing Shadcn tables will continue to work exactly as before. If you already have a table.tsx, the CLI will prompt you 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 issue 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
}

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 core once — one command copies the base table (Root, DataTable, context, structure, column header, empty state, hooks, lib, types) 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 the core, so the CLI will install or reuse it.

Now install the core:

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 only the core. For pagination, filters, DnD, virtualization, aside, and other features, add the optional blocks below (one by one) or use Install Everything.

Want all components at once? The following command installs core + all optional add-ons in one go:

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

If you prefer not to configure the registry, you can install core and every optional block in one command using URLs:

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-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-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"

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"

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"

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"

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"

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: "[email protected]", status: "active" },
    { id: "2", name: "Jane Smith", email: "[email protected]", status: "active" },
    { id: "3", name: "Bob Johnson", email: "[email protected]", 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-green-600"
    : "text-gray-400"
    }
    >
    {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
  • Shadcn: table
  • @tanstack/react-table
  • Shadcn: table, button, dropdown-menu
  • @tanstack/react-table
  • Shadcn: table, button, input, dropdown-menu
  • @tanstack/react-table
  • Shadcn: table, button, input, dropdown-menu, popover, command, checkbox, select
  • @tanstack/react-table
  • Shadcn: table, button, checkbox, dropdown-menu
  • @tanstack/react-table
  • Shadcn: table, button, input, dropdown-menu
  • @tanstack/react-table
  • Shadcn: table, button, input, dropdown-menu
  • @tanstack/react-table
  • @tanstack/react-virtual
  • Shadcn: table, button, input, dropdown-menu, scroll-area
  • @tanstack/react-table
  • 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): DiceUI Sortable - @dnd-kit/core, @dnd-kit/modifiers, @dnd-kit/sortable, @dnd-kit/utilities, @radix-ui/react-slot
  • @tanstack/react-table
  • 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): DiceUI Sortable - @dnd-kit/core, @dnd-kit/modifiers, @dnd-kit/sortable, @dnd-kit/utilities, @radix-ui/react-slot

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, follow the DiceUI Sortable installation guide.

If you want to install everything upfront — core, all add-ons, and optional npm dependencies:

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

For optional dependencies used by specific examples (not required for all projects):

pnpm add nuqs @tanstack/react-query
pnpm dlx shadcn@latest add checkbox card

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: "[email protected]" },
{ id: "2", name: "Jane Smith", email: "[email protected]" },
]
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: