Virtualisation

Container, window, and custom-scroll virtualisation modes for large datasets.

Overview

Virtualisation keeps large tables usable by rendering only the visible rows plus an overscan buffer. DataTable supports three layouts:

ModeWhen To UseKey Props
Container virtualisationThe table scrolls inside its own fixed-height containerenableRowVirtualization, virtualMaxHeight
Window virtualisationThe page itself is the scroll containerenableRowVirtualization, useBodyScroll
Custom scroll containerAnother element owns scrollingenableRowVirtualization, useBodyScroll, getScrollElement

Container Virtualisation

Container virtualisation is the default mode once enableRowVirtualization is on.

<DataTable
  columns={columns}
  data={rows}
  enableRowVirtualization
  virtualMaxHeight={500}
  virtualRowHeight={40}
  virtualOverscan={8}
/>

Window and Custom Scroll Virtualisation

Use useBodyScroll when the scroll position should come from the page or from another scroll container.

<DataTable
  columns={columns}
  data={rows}
  enableRowVirtualization
  useBodyScroll
  getScrollElement={() => scrollContainerRef.current}
  virtualRowHeight={40}
  virtualOverscan={50}
/>

Row Measurement

DataTable estimates row height from virtualRowHeight and measures row elements dynamically during virtualisation. Give virtualRowHeight a realistic estimate to reduce layout correction.

Provide measureElement only when you need custom measurement behavior.

API Reference

PropTypeDefaultDescription
enableRowVirtualizationbooleanfalseEnable row virtualisation
virtualRowHeightnumber40Estimated row height in pixels
virtualOverscannumber20Extra rows rendered above and below the viewport
virtualMaxHeightnumber | string600Max container height in container virtualisation mode
useBodyScrollbooleanfalseUse the page or another element as the scroll container
getScrollElement() => HTMLElement | null-Custom scroll element getter for body-scroll virtualisation
measureElement(element: Element, entry?: ResizeObserverEntry, instance?: any) => number-Custom row measurement logic
debugbooleanfalseLog virtualisation diagnostics to the console

On this page