Back to projects
Projectadvanced 8 steps ~110 min

Virtualized Data Grid

Render 10,000 rows smoothly with windowing, then add sorting, a sticky header, keyboard navigation, and selection, with logic split into testable modules.

What you'll build

A data grid that scrolls 10k rows smoothly, sorts by column, and supports keyboard selection.

  • React
  • virtualization
  • useMemo
  • keyboard a11y
  • performance
Project briefrequirements and design decisions

Requirements

  • Handles 10,000+ rows with a constant number of DOM nodes
  • Scrolling stays smooth on a mid-range laptop (no long tasks over 50 ms)
  • Sort by any column, ascending and descending
  • Arrow keys move the active row; Space toggles selection
  • Header stays visible while scrolling

Architecture decisions

  • Fixed row height makes visible-range math O(1)
  • Overscan rows above and below the viewport hide blank flashes
  • Sorting is memoized and separated from rendering
  • Selection stored as a Set of ids, not row indexes, so it survives sorting

Stretch goals

  • Variable row heights with measured and cached sizes
  • Column resizing and reordering
  • Server-side sorting and paging for 1M rows

Production checklist

  • ARIA grid semantics (role=grid, aria-rowcount, aria-rowindex)
  • Performance test in CI with a long-task budget
  • Screen-reader testing of virtualized rows

1What we're building

Admin tools, analytics products, and CRMs all eventually need a table with thousands of rows. Rendering 10,000 rows × 4 cells creates 40,000+ DOM nodes. Initial render takes seconds, scrolling janks, and memory climbs.

You'll build a virtualized data grid, organized so logic and view stay separate:

1data.js 10,000 generated rows + layout constants 2virtual.js pure windowing math: which rows are visible? 3sortRows.js pure sorting helpers 4useGridKeyboard.js keyboard model: active row, selection, scroll-into-view 5grid.css styles 6App.jsx the view: wires it all together

The pure modules (virtual.js, sortRows.js) have no React in them. They're the parts you'd unit test, and the parts you could reuse in a different grid.

The key idea of virtualization: a tall spacer element gives the scroll container its full height (10,000 × 36 px), and only the visible rows are rendered, absolutely positioned at their offsets. The browser scrolls as if every row existed.

Virtualized Data Grid project | Bloom