Skip to main content

Data table

A generic table built on @tanstack/react-table: sorting, pagination, and a column-visibility dropdown out of the box. Re-exports ColumnDef so you can define columns without a separate import.

import { DataTable, type ColumnDef } from '@rtorcato/shadcn-ui/components/ui-extended/data-table'

Usage

type Payment = { id: string; amount: number; status: string }

const columns: ColumnDef<Payment>[] = [
{ accessorKey: 'status', header: 'Status' },
{ accessorKey: 'amount', header: 'Amount' },
]

<DataTable columns={columns} data={payments} pageSize={10} />

Props

PropTypeDefaultDescription
columnsColumnDef<TData>[]TanStack column definitions.
dataTData[]Rows to render.
pageSizenumber10Rows per page.
classNamestringWrapper class.