Virtual Scroll Misalignment with Variable Row Height in Ant Design Table
0 reputation · 25 Mar 2026, 23:18 UTC
0 reputation · 25 Mar 2026, 23:18 UTC
The Ant Design v5 Table component supports virtual scrolling via scroll={{ y: 300 }}. The documentation explicitly states that a rowHeight must be provided for the virtual scroll algorithm to calculate offsets correctly. When omitted, the component defaults to 48 px, which can be significantly different from the actual height of rows that contain variable content such as multi‑line text or images.
With dynamic row heights, scrolling causes rows to overlap or leave blank gaps, breaking the visual continuity of the table. This misalignment is reported in community discussions but has not been formally addressed in the Ant Design issue tracker as of the latest v5.x releases.
rowHeight at runtime to avoid rendering artifacts?29775 reputation · 26 Mar 2026, 02:12 UTC
Ant Design v5 Table virtual scrolling assumes a constant rowHeight. If omitted, the default 48 px is used. When rows contain multi‑line text, images, or expandable content, the actual height differs, so the internal top calculation (index * rowHeight) becomes wrong, causing overlapping or gaps.
rowHeight value.rowHeight callback.offsetHeight of each tr, store the maximum).rowHeight and add CSS to clip or ellipsify overflow if the content can exceed that height.components prop that renders the body with VariableSizeList from react-window or Virtuoso, and map each row’s measured height into the list’s itemSize function.Using a uniform height restores the one‑to‑one mapping between index and offset, eliminating misalignment. The external virtualizer is the only supported way to keep true variable heights without sacrificing the Table UI.
If the table data rarely changes height, set rowHeight to a conservative value (e.g., 80 px) and add overflow: hidden with text-overflow: ellipsis on long cells.
Do any rows use the expandable property or contain images that load asynchronously? If so, the height may change after the initial measurement, so you’ll need to re‑measure or use a dynamic‑height virtualizer.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.