Introduction
What Niko Table is, how it is built, and why you copy the code instead of installing a package.
What is this registry?
Section titled “What is this registry?”Nobody’s table, everyone’s solution.
Like shadcn, this is not a component library. It is a registry of DataTable* components. You copy them into your project and change them as you like.
- Built with: TanStack Table and Shadcn UI. Every component reuses the shadcn/ui components in your project, so it matches your theme.
- Registry name:
niko-table(@niko-table/...). - What you use:
DataTable,DataTableRootand related components.
Why Use This DataTable?
Section titled “Why Use This DataTable?”🚀 Production-Ready
Section titled “🚀 Production-Ready”Features for real apps:
- Sorting (single and multi-column)
- Filtering (global search and column filters)
- Pagination (client and server-side)
- Row selection and bulk actions
- Column visibility and reordering
- Virtual scrolling for large datasets
- Export to CSV
🎯 Progressive Complexity
Section titled “🎯 Progressive Complexity”Start simple. Add features when you need them:
- Simple Table - Just render data (< 5 minutes)
- Basic Table - Add pagination and sorting (+ 5 minutes)
- Search Table - Add global search (+ 5 minutes)
- Filter Table - Add column filters (+ 10 minutes)
- Advanced Table - Add virtualization, sidebars, etc. (+ 15 minutes)
🛠️ Fully Customizable
Section titled “🛠️ Fully Customizable”You own the code, so you can:
- Change any component
- Add your own features
- Change the styling
- Connect it to your backend
- Stay free of version lock-in
♿ Accessible by Default
Section titled “♿ Accessible by Default”Built on the primitives your shadcn style uses (Radix UI or Base UI), with semantic table markup where possible:
- Keyboard support in sort/filter menus and toolbar controls
- ARIA labels on filter triggers, sliders, and clear actions
- Screen-reader-friendly patterns from shadcn/ui components
- jsx-a11y lint rules on docs and source
We do not claim WCAG certification from a third party. Complex tables (virtualization, DnD, pinning) are custom UI, so check them against your own accessibility list.
📱 Responsive layout
Section titled “📱 Responsive layout”DataTablehas a full-widthoverflow-autoscroll area, so wide tables scroll on small screens.- Popovers and filter panels fit the viewport width.
DataTableAside(optional) adds a collapsible detail panel. See Aside Table.- Toolbars are plain flex layouts. Wrap or hide filters on mobile in your app.
How It Works
Section titled “How It Works”DataTable has two layers:
Components (data-table-*.tsx in /components): wrappers that get the table from DataTableRoot context through useDataTable(). You do not pass props down. This is the recommended layer:
DataTableSearchFilter,DataTableFilterMenu,DataTableSortMenu,DataTablePagination, etc.
Filters (table-*.tsx in /filters): the core pieces. They take a table prop and read the TanStack Table instance (like table.state and table.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: use them to build your own components or manage the table instance yourself.- Your control: all filter components use TanStack Table hooks directly.
// Recommended: Use context-based Action components<DataTableRoot data={data} columns={columns}> <DataTableSearchFilter /> {/* Automatically gets table from context */} <DataTable> <DataTableHeader /> <DataTableBody /> </DataTable> <DataTablePagination /></DataTableRoot>
// Advanced: Use Filter components directly// `features` comes from @/components/niko-table/lib/data-table-featuresconst table = useTable({ features, data, columns, ... })<TableSearchFilter table={table} /> {/* Pass table prop directly */}Build tables by composing components. Start simple and add features as needed:
<DataTableRoot data={data} columns={columns}> <DataTableToolbarSection> <DataTableSearchFilter /> <DataTableFilterMenu /> </DataTableToolbarSection>
<DataTable> <DataTableHeader /> <DataTableBody /> </DataTable>
<DataTablePagination /></DataTableRoot>Composability map
Section titled “Composability map”DataTable is mix-and-match:
- Install only the registry items you need.
- Render only the children you want.
- Swap body types without rewriting column defs.
TanStack Table v9 works the same way. v8 put every behavior in useReactTable. v9 lets you import only what you need through lib/data-table-features.ts. Trim that file after install, like skipping components you never use.
| Layer | What you choose | Notes |
|---|---|---|
| Root | DataTableRoot |
Required. Optional controlled state, config overrides, getRowId for selection/DnD/expansion |
| Toolbar | DataTableToolbarSection + any of search, faceted, filter menu, view menu, clear |
Omitted entirely for minimal tables |
| Table shell | DataTable with height / max-h-* when virtualizing |
Virtualizer needs a bounded scroll container |
| Header / body | Regular: DataTableHeader + DataTableBody |
Default path |
Virtualized: DataTableVirtualizedHeader + DataTableVirtualizedBody |
100k+ rows | |
Row DnD: DataTableRowDndProvider (outside table) + DataTableDndBody |
Do not combine with sort/filter | |
Column DnD: DataTableColumnDndProvider + draggable headers/cells |
Safe with other features | |
| Loading / empty | DataTableSkeleton, DataTableEmptyBody or composable empty pieces |
Siblings inside the body |
| Footer | DataTablePagination, DataTableSelectionBar |
Optional |
| Row actions | One RowMenu* component + useDataTableRow in kebab and DataTableRowContextMenuSlot |
Row context menu |
| Escape hatch | Table* filters with your own table instance |
Custom layouts without context |
DataTableRoot detects features from its children (detectFeaturesFromChildren). Pagination, filtering and sorting turn on when you add the matching components. You rarely need a big config object.
What’s Included
Section titled “What’s Included”You get:
- TanStack Table integration - Built on the headless table library
- Composable components - Build complex UIs from small pieces
- State management - State shared through context, with hooks
- Performance - Virtual scrolling, memoization and efficient rendering
- Accessibility - shadcn/ui primitives (Radix UI, Base UI or React Aria), keyboard-friendly filters and menus, jsx-a11y linting (test it in your own app)
- TypeScript - Fully typed
Philosophy
Section titled “Philosophy”This project follows the shadcn approach:
Copy, Don’t Install
Section titled “Copy, Don’t Install”You copy the DataTable code into your project. It is not a package. You still install its dependencies:
Required Dependencies:
@tanstack/react-table@^9- Core table library (v9: register features inlib/data-table-features.ts)- Shadcn UI components (via
npx shadcn@latest add ...) - UI primitives - Optional:
@tanstack/react-virtual,nuqsand@dnd-kit/*for advanced features
What You Copy:
- All DataTable component files from
/components/niko-table/ - Source code you can read and change
Benefits:
- ✅ No black box - See how it works
- ✅ Full control - Change any component
- ✅ Easy to customize - Change styling and behavior, or add features
- ✅ No version lock-in - You choose when to update
- ✅ Learn by reading - Read the real code
Composition Over Configuration
Section titled “Composition Over Configuration”Build complex tables from small components. Register only the TanStack features those pieces need. Registry installs and lib/data-table-features.ts follow the same idea at two layers:
// Start simple<DataTableRoot data={data} columns={columns}> <DataTable> <DataTableHeader /> <DataTableBody /> </DataTable></DataTableRoot>
// Add features incrementally<DataTableRoot data={data} columns={columns} config={{ enablePagination: true }}> <DataTableToolbarSection> <DataTableSearchFilter /> </DataTableToolbarSection>
<DataTable> <DataTableHeader /> <DataTableBody /> </DataTable>
<DataTablePagination /></DataTableRoot>
// Go advanced<DataTableRoot data={data} columns={columns} config={{ enablePagination: true, enableFilters: true, enableRowSelection: true, }}> <DataTableToolbarSection className="justify-between"> <div className="flex gap-2"> <DataTableSearchFilter /> <DataTableFilterMenu /> </div> <div className="flex gap-2"> <DataTableViewMenu /> <DataTableSortMenu /> </div> </DataTableToolbarSection>
<DataTable> <DataTableHeader /> <DataTableBody> <DataTableSkeleton /> <DataTableEmptyBody /> </DataTableBody> </DataTable>
<DataTablePagination /></DataTableRoot>Type-Safe by Default
Section titled “Type-Safe by Default”Typed throughout:
type User = { id: string name: string email: string}
const columns: DataTableColumnDef<User>[] = [ { accessorKey: "name", // ✅ Type-safe header: "Name", cell: ({ row }) => row.original.email, // ✅ Autocomplete },]Comparison
Section titled “Comparison”vs Component Libraries
Section titled “vs Component Libraries”| Feature | This DataTable | Component Libraries |
|---|---|---|
| Customization | ✅ Full control | ❌ Limited |
| Bundle size | ✅ Copy what you need | ❌ Entire library |
| Learning curve | ✅ See the source | ❌ Read docs |
| Dependencies | ✅ Standard deps only | ❌ Library-specific |
| Updates | ✅ Copy new features | ❌ Breaking changes |
vs Building from Scratch
Section titled “vs Building from Scratch”| Feature | This DataTable | From Scratch |
|---|---|---|
| Time to implement | ✅ Minutes | ❌ Days/weeks |
| Accessibility | ✅ Baseline included | ❌ Must implement |
| Mobile support | ✅ Ready | ❌ Must build |
| Advanced features | ✅ Available | ❌ Complex to build |
| Best practices | ✅ Included | ❌ Must learn |
Next Steps
Section titled “Next Steps”Ready to start?
- Installation - Set up your project
- Simple Table - Your first table
- Basic Table - Add common features
- Search Table - Add search
- Faceted Filter Table - Column filters
- Advanced Table - All features
Community
Section titled “Community”Questions, ideas or fixes?
- GitHub Repository - Give it a star
- Contributing Guide - How to help
- Feature Requests - Ask for a feature
- Component Requests - Ask for a component
Credits
Section titled “Credits”Built on top of:
- TanStack Table by Tanner Linsley - The headless table library behind it all
- Shadcn UI by Shadcn - Accessible component primitives
- sadmann7’s work - Main inspiration for the filter components and table patterns:
- TableCN - Inspired our filter menu, inline filter, faceted filter and slider filter
- DiceUI Sortable - Drag and drop sorting for row reordering
- nuqs by François Best - Type-safe URL state
- Web Dev Simplified Registry by Kyle Cook - Registry pattern
License
Section titled “License”MIT License. Use it in your projects.