Skip to content
Niko Table

Introduction

What Niko Table is, how it is built, and why you copy the code instead of installing a package.

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, DataTableRoot and related components.

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

Start simple. Add features when you need them:

  1. Simple Table - Just render data (< 5 minutes)
  2. Basic Table - Add pagination and sorting (+ 5 minutes)
  3. Search Table - Add global search (+ 5 minutes)
  4. Filter Table - Add column filters (+ 10 minutes)
  5. Advanced Table - Add virtualization, sidebars, etc. (+ 15 minutes)

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

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.

  • DataTable has a full-width overflow-auto scroll 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.

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

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.

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

This project follows the shadcn approach:

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 in lib/data-table-features.ts)
  • Shadcn UI components (via npx shadcn@latest add ...) - UI primitives
  • Optional: @tanstack/react-virtual, nuqs and @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

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>

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
},
]
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
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

Ready to start?

  1. Installation - Set up your project
  2. Simple Table - Your first table
  3. Basic Table - Add common features
  4. Search Table - Add search
  5. Faceted Filter Table - Column filters
  6. Advanced Table - All features

Questions, ideas or fixes?

Built on top of:

MIT License. Use it in your projects.