BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/tablecn/data-grid

Data Grid

tablecn/data-grid
FreeComponent

A high-performance editable data grid component with virtualization, keyboard navigation, and cell editing

Install it

npx shadcn@latest add https://tablecn.com/r/data-grid.json

Source

src/components/data-grid/data-grid.tsxtablecn.com/r/data-grid.json · first 6 KB
1"use client";
2
3import { Plus } from "lucide-react";
4import * as React from "react";
5import { DataGridColumnHeader } from "@/components/data-grid/data-grid-column-header";
6import { DataGridContextMenu } from "@/components/data-grid/data-grid-context-menu";
7import { DataGridPasteDialog } from "@/components/data-grid/data-grid-paste-dialog";
8import { DataGridRow } from "@/components/data-grid/data-grid-row";
9import { DataGridSearch } from "@/components/data-grid/data-grid-search";
10import { useAsRef } from "@/hooks/use-as-ref";
11import type { useDataGrid } from "@/hooks/use-data-grid";
12import {
13 flexRender,
14 getColumnBorderVisibility,
15 getColumnPinningStyle,
16} from "@/lib/data-grid";
17import { cn } from "@/lib/utils";
18import type { Direction } from "@/types/data-grid";
19
20const EMPTY_CELL_SELECTION_SET = new Set<string>();
21
22interface DataGridProps<TData>
23 extends Omit<ReturnType<typeof useDataGrid<TData>>, "dir">,
24 Omit<React.ComponentProps<"div">, "contextMenu"> {
25 dir?: Direction;
26 height?: number;
27 stretchColumns?: boolean;
28}
29
30export function DataGrid<TData>({
31 dataGridRef,
32 headerRef,
33 rowMapRef,
34 footerRef,
35 dir = "ltr",
36 table,
37 tableMeta,
38 virtualTotalSize,
39 virtualItems,
40 measureElement,
41 columns,
42 columnSizeVars,
43 searchState,
44 searchMatchesByRow,
45 activeSearchMatch,
46 cellSelectionMap,
47 focusedCell,
48 editingCell,
49 rowHeight,
50 contextMenu,
51 pasteDialog,
52 onRowAdd: onRowAddProp,
53 height = 600,
54 stretchColumns = false,
55 adjustLayout = false,
56 className,
57 ...props
58}: DataGridProps<TData>) {
59 const rows = table.getRowModel().rows;
60 const readOnly = tableMeta?.readOnly ?? false;
61 const columnVisibility = table.getState().columnVisibility;
62 const columnPinning = table.getState().columnPinning;
63
64 const onRowAddRef = useAsRef(onRowAddProp);
65
66 const onRowAdd = React.useCallback(
67 (event: React.MouseEvent<HTMLDivElement>) => {
68 onRowAddRef.current?.(event);
69 },
70 [onRowAddRef],
71 );
72
73 const onDataGridContextMenu = React.useCallback(
74 (event: React.MouseEvent<HTMLDivElement>) => {
75 event.preventDefault();
76 },
77 [],
78 );
79
80 const onFooterCellKeyDown = React.useCallback(
81 (event: React.KeyboardEvent<HTMLDivElement>) => {
82 if (!onRowAddRef.current) return;
83
84 if (event.key === "Enter" || event.key === " ") {
85 event.preventDefault();
86 onRowAddRef.current();
87 }
88 },
89 [onRowAddRef],
90 );
91
92 return (
93 <div
94 data-slot="grid-wrapper"
95 dir={dir}
96// … truncated

What it pulls in

npm packages

  • @tanstack/react-table
  • @tanstack/react-virtual
  • lucide-react
  • sonner

Other registry items

  • badge
  • button
  • calendar
  • checkbox
  • command
  • dialog
  • dropdown-menu
  • input
  • popover
  • select
  • separator
  • skeleton
  • textarea
  • tooltip

Files it writes

  • src/components/data-grid/data-grid.tsx
  • src/components/data-grid/data-grid-presence.tsx
  • src/components/data-grid/data-grid-cell.tsx
  • src/components/data-grid/data-grid-cell-wrapper.tsx
  • src/components/data-grid/data-grid-cell-variants.tsx
  • src/components/data-grid/data-grid-column-header.tsx
  • src/components/data-grid/data-grid-context-menu.tsx
  • src/components/data-grid/data-grid-paste-dialog.tsx
  • src/components/data-grid/data-grid-row.tsx
  • src/components/data-grid/data-grid-search.tsx
  • src/components/ui/direction.tsx
  • src/hooks/use-as-ref.ts
  • src/hooks/use-badge-overflow.ts
  • src/hooks/use-callback-ref.ts
  • src/hooks/use-data-grid.ts
  • src/hooks/use-debounced-callback.ts
  • src/hooks/use-isomorphic-layout-effect.ts
  • src/hooks/use-lazy-ref.ts
  • src/lib/compose-refs.ts
  • src/lib/data-grid.ts
  • src/types/data-grid.ts

Facts

Registry
tablecn
Type
registry:component
Access
Free
Files written
21
Licence
MIT
First indexed
2026-08-01
Last confirmed
yesterday

Go to the source

tablecn.com sadmann7/tablecn on GitHub Raw registry item This item as JSON

More from tablecn

All 13 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Data Grid Filter Menudata-grid-filter-menutablecnComponentsFree2 deps · 8 files
Data Grid Keyboard Shortcutsdata-grid-keyboard-shortcutstablecnComponentsFree1 dep · 2 files
Data Grid Row Height Menudata-grid-row-height-menutablecnComponentsFree2 deps
Data Grid Select Columndata-grid-select-columntablecnComponentsFree1 dep
Data Grid Skeletondata-grid-skeletontablecnComponentsFreeno deps
Data Grid Sort Menudata-grid-sort-menutablecnComponentsFree2 deps · 4 files
Data Grid View Menudata-grid-view-menutablecnComponentsFree2 deps · 2 files
Data Tabledata-tabletablecnComponentsFree3 deps · 17 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