Skip to main content

DataGrid

The DataGrid component wraps Table with a header, filter sidebar, pagination, and optional add button.

Props

PropTypeDescription
dataGridDataGridType<T>Config object from useDataGrid()
tableTable<T>TanStack Table instance from useDataGrid()
titlestringHeader title
subtitlestring?Header subtitle
addstring | boolean?URL for add button, or true to use ${pathname}/add
filterActionstring?Custom form action for filters
actionsSnippet?Additional action buttons rendered in the header
filterFieldsSnippet?Filter form fields rendered in the sidebar

useDataGrid

Creates and configures a data grid. Returns { table, dataGrid, filterData }.

import { useDataGrid } from '@repo/table';

const { table, dataGrid } = useDataGrid({
tableOptions: {
columns: [...],
},
data: { data: items, count: totalCount },
getRowLink: (row) => `/items/${row.original.id}`,
});

Options

OptionTypeDescription
tableOptionsPartial<TableOptions<T>>TanStack Table config (columns, initial state, etc.)
dataPaginatedResult<T>{ data: T[], count: number }
getRowLink(row: Row<T>) => string?Row click link generator
filterFormSuperValidated?SuperForms validated form for filters
filterSchemaz.ZodObject?Zod schema for filter fields
sortStrategySortingStrategy?Custom sort strategy (default: urlSortStrategy)
paginationStrategyPaginationStrategy?Custom pagination strategy (default: urlPaginationStrategy)
filterStrategyFilterStrategy?Custom filter strategy (default: urlFilterStrategy)

Return Value

PropertyTypeDescription
tableTable<T>TanStack Table instance
dataGridDataGridType<T>Pass to DataGrid component
filterDataWritable?Reactive filter form data (if filters configured)

Lower-level Components

Table

Renders the table body without header/pagination chrome.

<script lang="ts">
import { Table } from '@repo/table';
</script>

<Table
{table}
getRowLink={(row) => `/items/${row.original.id}`}
useColumnManagement={true}
/>
PropTypeDescription
tableTable<T>TanStack Table instance
getRowLink(row: Row<T>) => string?Row link generator
useColumnManagementboolean?Enable column visibility toggles

TableRow

Single row renderer.

<TableRow {row} {getRowLink} />

TableHeadCell

Header cell with sorting indicator.

<TableHeadCell {header} />

Pagination

Pagination controls.

<Pagination {table} paginationStrategy={dataGrid.paginationStrategy} />