Manual Installation
Copy the DataTable files into your project by hand.
Prerequisites
Section titled “Prerequisites”You need:
- A React project (Next.js, Vite, etc.)
- Shadcn UI set up in your project (Installation Guide)
- TailwindCSS configured
- TypeScript (recommended)
Using Base UI (
"style": "base-nova")? Use the CLI install instead.
- The CLI changes the source to Base UI idioms (
asChildbecomesrender) during install.- The files on this page are for Radix (
new-york).
Architecture Note
Section titled “Architecture Note”DataTable has two layers:
- Components (
data-table-*.tsxin/components): wrappers that get the table fromDataTableRootcontext throughuseDataTable(). You do not pass props down. This is the recommended layer:DataTableSearchFilter,DataTableFilterMenu,DataTableSortMenu,DataTablePagination, etc.
- Filters (
table-*.tsxin/filters): the core pieces. They take atableprop and read the TanStack Table instance (liketable.stateandtable.setGlobalFilter()). You can use them on their own:TableSearchFilter,TableFilterMenu,TableSortMenu, etc.
Why two layers?
DataTable*components: import from their direct paths (e.g.@/components/niko-table/components/data-table-pagination). They work with no setup.Table*filters: import from filters (e.g.@/components/niko-table/filters/table-pagination). Use them to build your own components or manage the table instance yourself.- Your control: all filter components use TanStack Table hooks directly.
Installation Steps
Section titled “Installation Steps”-
Install the required dependencies
This registry uses TanStack Table v9:
pnpm add @tanstack/react-table@^9You also need
lib/data-table-features.tsfrom the files below. It is thetableFeatures()list thatDataTableRootpasses touseTable. See Table Features. -
Install the required Shadcn UI components
The registry adds most Shadcn dependencies for you. For a manual install, you need:
pnpm dlx shadcn@latest add button input dropdown-menu -
Copy the custom table component
DataTable needs a custom
components/ui/table.tsxthat exportsTableComponent. Copy it from the files below, or install it with the registry CLI (see the Installation Guide). -
Copy all DataTable components
Copy all the files below into your project. Keep the folder structure shown.
-
Update import paths
Change the import paths in the copied files to match your project. The components use:
-
@/components/ui/for Shadcn UI components -
@/components/niko-table/for DataTable components -
@/lib/for utility functions -
Make sure the
@/path alias points at yoursrc/directory. Or replace@/with your own alias in the copied code. -
Use direct file imports only (no barrel exports). Import from the specific file, e.g.
@/components/niko-table/core/data-table-rootor@/components/niko-table/lib/constants. This lets bundlers tree-shake, and matches the shadcn pattern of one entry point per component.
-
-
Verify installation
Render a small table to check that it works:
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 = []export function TestTable() {return (<DataTableRoot data={data} columns={columns}><DataTable><DataTableHeader /><DataTableBody /></DataTable></DataTableRoot>)}
Project Structure
Section titled “Project Structure”After copying all files, your project looks like this:
your-project/├── src/│ ├── components/│ │ ├── ui/│ │ │ ├── table.tsx # Updated Shadcn table component│ │ │ ├── button.tsx│ │ │ ├── input.tsx│ │ │ ├── dropdown-menu.tsx│ │ │ └── ... # Other Shadcn components│ │ ││ │ └── niko-table/│ │ ││ │ ├── core/ # Core table components│ │ │ ├── data-table.tsx # Container + scroll wrapper│ │ │ ├── data-table-root.tsx # Top-level provider + table options│ │ │ ├── data-table-context.tsx # useDataTable() context│ │ │ ├── data-table-error-boundary.tsx # Error boundary wrapper│ │ │ ├── data-table-structure.tsx # Header, Body, EmptyBody, Skeleton, Loading, LoadingMore│ │ │ ├── data-table-row-dnd-structure.tsx # Row DnD body│ │ │ ├── data-table-column-dnd-structure.tsx # Column DnD header/body│ │ │ ├── data-table-virtualized-structure.tsx # VirtualizedHeader, VirtualizedBody, VirtualizedEmptyBody, VirtualizedSkeleton, VirtualizedLoading, VirtualizedLoadingMore│ │ │ ├── data-table-virtualized-row-dnd-structure.tsx # Virtualized row DnD body│ │ │ └── data-table-virtualized-column-dnd-structure.tsx # Virtualized column DnD header/body│ │ ││ │ ├── components/ # Context-aware user-facing components│ │ │ ├── data-table-search-filter.tsx│ │ │ ├── data-table-view-menu.tsx│ │ │ ├── data-table-view-dnd-menu.tsx│ │ │ ├── data-table-filter-menu.tsx│ │ │ ├── data-table-sort-menu.tsx│ │ │ ├── data-table-clear-filter.tsx│ │ │ ├── data-table-faceted-filter.tsx│ │ │ ├── data-table-slider-filter.tsx│ │ │ ├── data-table-date-filter.tsx│ │ │ ├── data-table-inline-filter.tsx│ │ │ ├── data-table-pagination.tsx│ │ │ ├── data-table-export-button.tsx│ │ │ ├── data-table-row-dnd.tsx│ │ │ ├── data-table-column-dnd.tsx│ │ │ ├── data-table-column-resize.tsx # Opt-in <DataTableColumnResize />│ │ │ ├── data-table-column-auto-fit.tsx # Opt-in <DataTableColumnAutoFit /> (even-split fill)│ │ │ ├── data-table-column-actions.tsx│ │ │ ├── data-table-column-header.tsx│ │ │ ├── data-table-column-title.tsx│ │ │ ├── data-table-column-sort.tsx│ │ │ ├── data-table-column-hide.tsx│ │ │ ├── data-table-column-pin.tsx│ │ │ ├── data-table-column-group.tsx│ │ │ ├── data-table-column-filter.tsx│ │ │ ├── data-table-column-filter-trigger.tsx│ │ │ ├── data-table-column-faceted-filter.tsx│ │ │ ├── data-table-column-date-filter-options.tsx│ │ │ ├── data-table-column-slider-filter-options.tsx│ │ │ ├── data-table-aside.tsx│ │ │ ├── data-table-selection-bar.tsx│ │ │ ├── data-table-toolbar-section.tsx│ │ │ ├── data-table-row-context-menu.tsx # Per-row right-click menu primitive (+ open-row highlight)│ │ │ ├── data-table-row-context-menu-slot.tsx # Declarative <DataTableRowContextMenuSlot> for a body│ │ │ ├── data-table-row-menu.tsx # Polymorphic RowMenuItem/Sub/… + DataTableRowMenuScope + useDataTableRow│ │ │ └── data-table-empty-state.tsx│ │ ││ │ ├── grid/ # Niko Grid (optional — editable spreadsheet layer)│ │ │ ├── core/ # DataGrid, context, features, columns context│ │ │ ├── cells/ # Text / number / select / date / checkbox editors│ │ │ ├── components/ # Clipboard, fill, move, toolbar, status bar, …│ │ │ ├── hooks/ # useDataGrid, useGridColumns, useGridChanges, …│ │ │ ├── config/ # Keyboard shortcuts map│ │ │ └── types/ # CellState, GridRow, …│ │ ││ │ ├── filters/ # Core filter implementations (accept `table` prop directly)│ │ │ ├── table-search-filter.tsx│ │ │ ├── table-faceted-filter.tsx│ │ │ ├── table-slider-filter.tsx│ │ │ ├── table-range-filter.tsx│ │ │ ├── table-date-filter.tsx│ │ │ ├── table-inline-filter.tsx│ │ │ ├── table-filter-menu.tsx│ │ │ ├── table-clear-filter.tsx│ │ │ ├── table-view-menu.tsx│ │ │ ├── table-view-dnd-menu.tsx│ │ │ ├── table-sort-menu.tsx│ │ │ ├── table-pagination.tsx│ │ │ ├── table-export-button.tsx│ │ │ ├── table-row-dnd.tsx│ │ │ ├── table-column-dnd.tsx│ │ │ ├── table-column-actions.tsx│ │ │ ├── table-column-title.tsx│ │ │ ├── table-column-sort.tsx│ │ │ ├── table-column-hide.tsx│ │ │ ├── table-column-pin.tsx│ │ │ ├── table-column-group.tsx│ │ │ ├── table-column-faceted-filter.tsx│ │ │ ├── table-column-slider-filter.tsx│ │ │ └── table-column-date-filter.tsx│ │ ││ │ ├── config/ # Configuration + feature detection│ │ │ ├── data-table.ts│ │ │ └── feature-detection.ts│ │ ││ │ ├── hooks/ # Custom React hooks│ │ │ ├── use-debounce.ts│ │ │ ├── use-derived-column-title.ts│ │ │ ├── use-generated-options.ts│ │ │ ├── use-keyboard-shortcut.ts│ │ │ ├── use-data-table-flash.ts # flashRows / flashCells helpers│ │ │ └── use-data-table-scroll.ts # scrollRowIntoView helper│ │ ││ │ ├── lib/ # Utility functions│ │ │ ├── constants.ts│ │ │ ├── data-table.ts│ │ │ ├── data-table-features.ts # TanStack Table v9 tableFeatures() + createDataTableColumnHelper│ │ │ ├── filter-functions.ts│ │ │ ├── filter-rows.ts│ │ │ ├── build-faceted-options.ts│ │ │ ├── format.ts│ │ │ ├── styles.ts│ │ │ ├── column-resize-handle.tsx # Shared resize grip (headers)│ │ │ ├── flex-columns.ts # Flex fill + header-fit width resolution (on by default)│ │ │ ├── use-header-min-widths.ts # Header-fit: measure header labels off-DOM to floor widths│ │ │ ├── use-column-auto-fit.ts # Opt-in even-split fill: grow resizable columns to width on load│ │ │ ├── use-column-sizing-persistence.ts # Opt-in: persist resized widths to localStorage│ │ │ ├── create-scroll-handler.ts # Shared scroll-listener factory used by every body│ │ │ ├── render-cell-content.tsx # Grouped / aggregated / placeholder cell renderer│ │ │ └── row-click.ts # Shared row-click guard used by every body│ │ ││ │ └── types/ # TypeScript types│ │ └── index.ts│ ││ └── lib/│ └── utils.ts # cn() utility (already in your project)│└── package.json- Need only some pieces? Use the CLI install. Each registry item pulls in its own dependencies.
- Want the full tree? Copy by hand. This includes the optional Niko Grid under
grid/.
All Components
Section titled “All Components”Browse and copy each file below (includes grid/ when it exists on disk):
Additional Dependencies
Section titled “Additional Dependencies”Some features need extra dependencies:
URL State Management (nuqs)
Section titled “URL State Management (nuqs)”To keep table state in the URL:
pnpm add nuqsVirtualization
Section titled “Virtualization”For virtualized tables (and Niko Grid):
pnpm add @tanstack/react-virtualSortable Rows / Column DnD
Section titled “Sortable Rows / Column DnD”For drag-and-drop row or column reordering, install @dnd-kit/* as the row-dnd and column-dnd registry items do. Or follow the DiceUI Sortable installation guide.
Next Steps
Section titled “Next Steps”The components are installed. Try the examples:
- Simple Table - Basic table, no pagination
- Basic Table - Add pagination and sorting
- Search Table - Add search
- Faceted Filter Table - Add column filters
- Column Resize Table - Drag or double-click to set column widths
- Niko Grid - Editable spreadsheet on the virtualized table
- Advanced Table - All features together
- Components catalog - Every
@niko-table/*registry item