BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/shadcn-table-library/data-table

Data Table

shadcn-table-library/data-table
FreeBlock

Sortable, filterable, paginated client-side table with a composable filter toolbar.

Install it

npx shadcn@latest add https://shad-table.dev/r/data-table.json

Source

src/components/basic/data-table.tsxshad-table.dev/r/data-table.json · first 6 KB
1'use client'
2
3import {
4 flexRender,
5 getCoreRowModel,
6 getFilteredRowModel,
7 getPaginationRowModel,
8 getSortedRowModel,
9 useReactTable,
10} from '@tanstack/react-table'
11
12import type {
13 ColumnDef,
14 ColumnFiltersState,
15 SortingState,
16 Table as ReactTable,
17} from '@tanstack/react-table'
18
19import {
20 Table,
21 TableBody,
22 TableCell,
23 TableHead,
24 TableHeader,
25 TableRow,
26} from '../ui/table'
27import { useState } from 'react'
28import { Button } from '../ui/button'
29import {
30 ArrowDown,
31 ArrowUp,
32 ArrowUpDown,
33 ChevronLeft,
34 ChevronRight,
35 ChevronsLeft,
36 ChevronsRight,
37 X,
38} from 'lucide-react'
39import {
40 Select,
41 SelectContent,
42 SelectGroup,
43 SelectItem,
44 SelectTrigger,
45 SelectValue,
46} from '../ui/select'
47import { Input } from '../ui/input'
48
49interface DataTableProps<TData, TValue> {
50 columns: ColumnDef<TData, TValue>[]
51 data: TData[]
52 filters?: (table: ReactTable<TData>) => React.ReactNode
53}
54
55const PAGES_SIZE = [
56 {
57 label: '10',
58 value: '10',
59 },
60 {
61 label: '20',
62 value: '20',
63 },
64 {
65 label: '30',
66 value: '30',
67 },
68 {
69 label: '40',
70 value: '40',
71 },
72 {
73 label: '50',
74 value: '50',
75 },
76]
77
78export function DataTable<TData, TValue>({
79 columns,
80 data,
81 filters,
82}: DataTableProps<TData, TValue>) {
83 const [pagination, setPagination] = useState({
84 pageIndex: 0,
85 pageSize: 10,
86 })
87
88 const [columnFilters, setColumnFilters] = useState<ColumnFiltersState>([])
89 const [globalFilter, setGlobalFilter] = useState<string>('')
90 const [sorting, setSorting] = useState<SortingState>([])
91
92 const table = useReactTable({
93 data,
94 columns,
95 getCoreRowModel: getCoreRowModel(),
96 getFilteredRowModel: getFilteredRowModel(),
97 getSortedRowModel: getSortedRowModel(),
98 getPaginationRowModel: getPaginationRowModel(),
99 onPaginationChange: setPagination,
100 state: {
101 pagination,
102 sorting,
103 globalFilter,
104 columnFilters,
105 },
106 onSortingChange: setSorting,
107 onColumnFiltersChange: setColumnFilters,
108 onGlobalFilterChange: setGlobalFilter,
109 })
110
111 return (
112 <div>
113 <div className="flex mb-3 flex-row justify-between items-center">
114 <Input
115 type="text"
116 placeholder={'Search...'}
117 onChange={(e) => table.setGlobalFilter(e.target.value)}
118 className="filter-input w-64"
119 />
120 <div className="flex flex-row items-center gap-4">
121 {table.getState().columnFilters.length > 0 ? (
122 <Button
123// … truncated

What it pulls in

npm packages

  • @tanstack/react-table

Other registry items

  • table
  • button
  • select
  • input

Files it writes

  • src/components/basic/columns.tsx
  • src/components/basic/data-table.tsx
  • src/components/basic/index.tsx
  • src/components/DataTableFilter.tsx

Facts

Registry
shadcn-table-library
Type
registry:block
Access
Free
Files written
4
Licence
the repository states none
First indexed
2026-08-02
Last confirmed
today

Go to the source

shad-table.dev coros-hq/shadcn-table-library on GitHub Raw registry item This item as JSON

More from shadcn-table-library

All 16 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Comparison Tablecomparison-tableshadcn-table-libraryBlocksFree1 dep · 4 files
Density & Exportdensity-export-tableshadcn-table-libraryBlocksFree1 dep · 4 files
Editable Tableeditable-tableshadcn-table-libraryBlocksFree1 dep · 3 files
Grouped Tablegrouped-tableshadcn-table-libraryBlocksFree1 dep · 3 files
Heatmap Tableheatmap-tableshadcn-table-libraryBlocksFree1 dep · 4 files
Summary / KPI Tablekpi-tableshadcn-table-libraryBlocksFree1 dep · 5 files
Master-Detail Tablemaster-detail-tableshadcn-table-libraryBlocksFree1 dep · 4 files
Pivot Tablepivot-tableshadcn-table-libraryBlocksFree1 dep · 4 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