VirtualizationPreview
Control DataGrid row virtualization and inspect its resolved geometry.
Overview
DataGrid automatically virtualizes large final row models and keeps smaller tables in normal document flow. The decision uses the visible rows and columns after filtering, grouping, expansion, and pivoting, so the same table can move between native and virtual geometry as its view changes.
Leave rowVirtualization="auto" for normal use. Use "always" for a known
large surface or performance test, and "never" for a known-small table that
requires native row geometry. Vertical
Cell Spanning also requires "never".
Rows can have different heights and are measured after mounting.
estimatedRowHeight supplies the initial estimate. Adjust overscan only after
measuring visible blanking or unnecessary mounted work. Top- and bottom-pinned
rows remain mounted outside the virtual centre region.
Example
The toolbar is ordinary viewport content rather than a virtual row. Scroll it away to keep the table header at the top. Search to reduce the row model below the automatic threshold; clear the search to return to virtual geometry.
<DataGrid table={table}>
<DataGrid.Viewport
aria-label="Matters"
className="max-h-96"
rowVirtualization="auto"
>
<MattersToolbar />
</DataGrid.Viewport>
</DataGrid>Diagnostics
Use onDiagnosticsChange on performance and test surfaces that need the
configured and resolved geometry, render-work estimate, and input-versus-mounted
dimensions. No diagnostic snapshots are created when the callback is omitted.
Expanded detail content is not included in mounted row or cell counts.
<DataGrid.Viewport
aria-label="Matters"
onDiagnosticsChange={diagnosticsStore.publish}
/>API Reference
DataGrid.Viewport
| Prop | Type | Default | Description |
|---|---|---|---|
rowVirtualization | "auto" | "always" | "never" | "auto" | Selects adaptive, forced virtual, or forced native row geometry. |
virtualizationThreshold | number | 180000 | Render-work threshold used by automatic virtualization. |
virtualizationOverscan | number | 5 | Rows mounted beyond each visible edge. |
estimatedRowHeight | number | 48 | Initial pixel estimate used until each mounted row is measured. |
onDiagnosticsChange | (diagnostics: DataGridDiagnostics) => void | - | Reports geometry, render work, and input-versus-mounted dimensions. |
Virtualization limits mounted DOM nodes without changing the final row model. Table APIs and accessibility row counts continue to describe all rendered-model rows.
DataGridDiagnostics
| Field | Type | Description |
|---|---|---|
geometry.configured | "auto" | "always" | "never" | Requested row-virtualization mode. |
geometry.resolved | "native" | "virtual" | Geometry currently used by the viewport. |
geometry.reason | DataGridDiagnostics["geometry"]["reason"] | Reason for the resolved geometry. |
geometry.estimatedRenderWork | number | Estimated work used by automatic mode. |
geometry.renderWorkThreshold | number | Threshold compared with the estimate. |
inputs | DataGridDiagnosticsDimensions | Rows, columns, and body cells before virtualization. |
mounted | DataGridDiagnosticsDimensions | Data rows, columns, and body cells currently mounted. |
DataGridDiagnosticsDimensions
| Field | Type | Description |
|---|---|---|
bodyCells | number | Data-body cells in the snapshot. Expanded-detail content is excluded. |
columns | { start: number, center: number, end: number, total: number } | Visible column counts by pinning region and in total. |
rows | { top: number, center: number, bottom: number, total: number } | Data-row counts by pinning region and in total. |