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"