BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/niko-table/data-table

Data Table

niko-table/data-table
FreeBlock

Core DataTable component built with TanStack Table and Shadcn UI. Includes table structure, context, types, hooks, utilities, and base components (column header, toolbar section, empty state).

Install it

npx shadcn@latest add https://niko-table.com/r/data-table.json

Source

src/components/niko-table/core/data-table.tsxniko-table.com/r/data-table.json · first 6 KB
1"use client"
2
3/**
4 * niko-table — created by Semir N. (Semkoo, https://github.com/Semkoo) with AI assistance.
5 *
6 * Before reporting anything: please check the changelog first.
7 * - In-repo: ./CHANGELOG.md
8 * - Docs site: https://niko-table.com/changelog
9 *
10 * Found a bug or have a fix? Open an issue or PR on GitHub so other
11 * users (and future LLMs reading this code) benefit:
12 * https://github.com/Semkoo/niko-table-registry
13 */
14import React from "react"
15import { cn } from "@/lib/utils"
16import { TableComponent } from "@/components/ui/table"
17
18import { useColumnResizeInfo, useDataTable } from "./data-table-context"
19
20/**
21 * Extracts height from Tailwind arbitrary values (e.g., h-[600px], max-h-[400px]).
22 * Converts them to inline styles to ensure scroll events work reliably.
23 * For other height utilities, use the height/maxHeight props directly.
24 */
25function parseHeightFromClassName(className?: string) {
26 if (!className)
27 return { height: undefined, maxHeight: undefined, safeClassName: className }
28
29 const classes = className.split(/\s+/)
30 let height: string | undefined
31 let maxHeight: string | undefined
32 const remainingClasses: string[] = []
33
34 for (const cls of classes) {
35 // Match arbitrary values: h-[600px], max-h-[400px]
36 const heightMatch = cls.match(/^h-\[([^\]]+)\]$/)
37 const maxHeightMatch = cls.match(/^max-h-\[([^\]]+)\]$/)
38
39 if (heightMatch) {
40 height = heightMatch[1]
41 } else if (maxHeightMatch) {
42 maxHeight = maxHeightMatch[1]
43 } else {
44 remainingClasses.push(cls)
45 }
46 }
47
48 return {
49 height,
50 maxHeight,
51 safeClassName: remainingClasses.join(" "),
52 }
53}
54
55export interface DataTableContainerProps {
56 children: React.ReactNode
57 /**
58 * Additional CSS classes for the container.
59 * Arbitrary height values (e.g., h-[600px], max-h-[400px]) are automatically extracted
60 * and applied as inline styles to ensure scroll event callbacks work reliably.
61 * For other height utilities, use the height/maxHeight props directly.
62 */
63 className?: string
64 /**
65 * Sets the height of the table container.
66 * When provided, enables vertical scrolling and allows DataTableBody/DataTableVirtualizedBody
67 * to use onScroll, onScrolledTop, and onScrolledBottom callbacks.
68 * Takes precedence over height utilities in className.
69 */
70 height?: number | string
71 /**
72 * Sets the maximum height of the table container.
73 * Defaults to the height value if not specified.
74// … truncated

What it pulls in

npm packages

  • @tanstack/react-table
  • lucide-react

Other registry items

  • skeleton
  • alert
  • button
  • dropdown-menu
  • context-menu

Files it writes

  • src/components/ui/table.tsx
  • src/components/niko-table/core/data-table.tsx
  • src/components/niko-table/core/data-table-root.tsx
  • src/components/niko-table/core/data-table-context.tsx
  • src/components/niko-table/core/data-table-structure.tsx
  • src/components/niko-table/lib/column-resize-handle.tsx
  • src/components/niko-table/lib/flex-columns.ts
  • src/components/niko-table/lib/use-header-min-widths.ts
  • src/components/niko-table/components/data-table-row-context-menu.tsx
  • src/components/niko-table/components/data-table-row-context-menu-slot.tsx
  • src/components/niko-table/components/data-table-row-menu.tsx
  • src/components/niko-table/core/data-table-error-boundary.tsx
  • src/components/niko-table/components/data-table-column-header.tsx
  • src/components/niko-table/components/data-table-column-title.tsx
  • src/components/niko-table/components/data-table-column-actions.tsx
  • src/components/niko-table/components/data-table-column-filter.tsx
  • src/components/niko-table/components/data-table-toolbar-section.tsx
  • src/components/niko-table/components/data-table-empty-state.tsx
  • src/components/niko-table/filters/table-column-actions.tsx
  • src/components/niko-table/filters/table-column-title.tsx
  • src/components/niko-table/hooks/use-debounce.ts
  • src/components/niko-table/hooks/use-derived-column-title.ts
  • src/components/niko-table/hooks/use-generated-options.ts
  • src/components/niko-table/hooks/use-keyboard-shortcut.ts
  • src/components/niko-table/lib/constants.ts
  • src/components/niko-table/lib/data-table.ts
  • src/components/niko-table/lib/filter-functions.ts
  • src/components/niko-table/lib/filter-rows.ts
  • src/components/niko-table/lib/create-scroll-handler.ts
  • src/components/niko-table/lib/row-click.ts
  • src/components/niko-table/lib/format.ts
  • src/components/niko-table/lib/styles.ts
  • src/components/niko-table/config/data-table.ts
  • src/components/niko-table/config/feature-detection.ts
  • src/components/niko-table/types/index.ts
  • src/components/niko-table/hooks/use-data-table-scroll.ts
  • src/components/niko-table/hooks/use-data-table-flash.ts

Facts

Registry
niko-table
Type
registry:block
Access
Free
Files written
37
Licence
the repository states none
First indexed
2026-08-02
Last confirmed
yesterday

Go to the source

niko-table.com Semkoo/niko-table-registry on GitHub Raw registry item This item as JSON

More from niko-table

All 31 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Data Grid (editable)data-table-gridniko-tableBlocksFree1 dep · 31 files
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex