DataGrid
Root of the DataGrid compound: merges caller layout/loading props over
sensible defaults and provides the context consumed by the table parts.
Requires a TanStack table instance (throws without one). Applies
initialColumnPinning once on mount and auto-enables column pinning for it.
| Finish | Status | |||
|---|---|---|---|---|
| Carrara Marble | Stone | Honed | In stock | |
| White Oak Plank | Wood | Matte | In stock | |
| Basalt Slab | Stone | Polished | Made to order | |
| Brass Sheet | Metal | Brushed | In stock | |
| Linen Weave | Textile | Woven | Made to order |
Usage
@desk/ui/components/data-grid
<DataGrid recordCount={MATERIALS.length} table={table}>
<DataGridShell>
<DataGridTable />
</DataGridShell>
<DataGridPagination />
</DataGrid>Best practices
Reach for
DataGrid(notTable) when you need sorting, filtering, column pinning/visibility, or pagination —Tableis a plain styled HTML table with no data model.Pass a
useReactTableinstance astable—DataGridthrows "requires thetableprop" without one; column defs and row model live on that instance, not onDataGridprops.Render the satellite parts (
DataGridTable,DataGridPagination,DataGridColumnHeader/Filter/Visibility) insideDataGrid— they read the table + layout from its context and break outside it.Enable features through
tableLayout(columnsPinnable,columnsResizable,columnsVisibility, …) rather than styling rows manually; setinitialColumnPinningto pin on mount.
Props
DataGrid
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | ||
| className | string | ||
| emptyMessage | ReactNode | Content shown in place of rows when the table is empty. | |
| initialColumnPinning | ColumnPinningState | Initial pinned columns (applied once). | |
| loading | boolean | ||
| loadingMessage | ReactNode | ||
| loadingMode | "skeleton" | "spinner" | "skeleton" | How the loading state renders. |
| onRowClick | (row: TData) => void | Invoked when a body row is clicked; providing it makes rows interactive. | |
| recordCount | number | Total row count across all pages; drives pagination and the empty state. | |
| table | Table<TData> | TanStack table instance to render. Required by | |
| tableClassNames | { base?: string; header?: string; headerRow?: string; headerSticky?: string; body?: string; bodyRow?: string; footer?: string; edgeCell?: string; } | Per-slot class overrides for the table's structural elements. | |
| tableLayout | { dense?: boolean; cellBorder?: boolean; rowBorder?: boolean; rowRounded?: boolean; striped?: boolean; headerBackground?: boolean; headerBorder?: boolean; headerSticky?: boolean; width?: "auto" | "fix | Presentational toggles for density, borders, sticky/pinnable columns, and row sizing. | |
| virtualization | { enabled?: boolean; estimateSize?: number; overscan?: number; } | Row virtualization for large datasets. |
DataGridCheckbox
| Prop | Type | Default | Description |
|---|---|---|---|
| indeterminate | boolean | undefined | When true, displays an indeterminate state (dash icon). This is syntactic sugar for checked="indeterminate". | |
| size | DataGridControlSize |
DataGridExpandToggle
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | CSS class name | |
| collapsedIcon | React.ComponentType<React.SVGProps<SVGSVGElement>> | Collapsed icon | |
| expandedIcon | React.ComponentType<React.SVGProps<SVGSVGElement>> | Expanded icon | |
| row | Row<TData> |
DataGridFilterableHeader
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | ||
| className | string | ||
| column | Column<TData, TValue> | ||
| options | FilterOption[] | Filter options — enables the facets section | |
| showSearch | boolean | Control search: true = always, false = never, undefined = auto (> 5 options) | |
| showSelectedTags | boolean | Show selected values as dismissible Tag pills above the filter list |
DataGridProvider
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | ||
| className | string | ||
| emptyMessage | ReactNode | Content shown in place of rows when the table is empty. | |
| initialColumnPinning | ColumnPinningState | Initial pinned columns (applied once). | |
| loading | boolean | ||
| loadingMessage | ReactNode | ||
| loadingMode | "skeleton" | "spinner" | "skeleton" | How the loading state renders. |
| onRowClick | (row: TData) => void | Invoked when a body row is clicked; providing it makes rows interactive. | |
| recordCount | number | Total row count across all pages; drives pagination and the empty state. | |
| table | Table<TData> | TanStack table instance to render. Required by | |
| tableClassNames | { base?: string; header?: string; headerRow?: string; headerSticky?: string; body?: string; bodyRow?: string; footer?: string; edgeCell?: string; } | Per-slot class overrides for the table's structural elements. | |
| tableLayout | { dense?: boolean; cellBorder?: boolean; rowBorder?: boolean; rowRounded?: boolean; striped?: boolean; headerBackground?: boolean; headerBorder?: boolean; headerSticky?: boolean; width?: "auto" | "fix | Presentational toggles for density, borders, sticky/pinnable columns, and row sizing. | |
| virtualization | { enabled?: boolean; estimateSize?: number; overscan?: number; } | Row virtualization for large datasets. |
DataGridRowSelect
| Prop | Type | Default | Description |
|---|---|---|---|
| disabled | boolean | ||
| row | Row<TData> |
DataGridRowSelectAll
| Prop | Type | Default | Description |
|---|---|---|---|
| disabled | boolean | ||
| table | Table<TData> |
DataGridShell
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | Child elements | |
| className | string | CSS class name | |
| border | BorderStyle | Border style. Options: "solid" (default), "none", "dashed". | |
| ref | import("react").Ref<HTMLDivElement> | Ref to the container element |
Also exports
- const
createExpanderColumn - const
createSelectionColumn - const
dataGridAnatomy - interface
DataGridApiFetchParams - interface
DataGridApiResponse - interface
DataGridContextProps - interface
DataGridProps - interface
DataGridRequestParams - interface
FilterOption - const
useDataGrid
Anatomy
DataGridShell
data-gridFramed container providing context and layout for the grid
DataGridToolbar
data-grid-toolbarHeader bar with left and right action regions
ToolbarLeft
toolbar-leftLeading region for search and filters
ToolbarRight
toolbar-rightTrailing region for actions and controls
DataGridTable
data-grid-tableTanStack-powered table with header, body, and rows