VirtualList

Renders only the visible slice of a large list. Supports fixed item heights, dynamic (content-driven) heights, and infinite scroll.

Fixed height

Pass itemHeight as a number (px).

Item 1
Item 2
Item 3
Item 4

Dynamic height

Pass itemHeight="dynamic" for content-driven heights. Each item is measured after it renders. Use estimatedItemHeight to set the initial layout estimate.

Item 1 — This item has a longer description that wraps onto multiple lines to demonstrate dynamic height measurement.
Item 2
Item 3
Item 4

Infinite scroll

Pass hasMore, loadingMore, and onLoadMore. The callback fires when the scroll position is within loadMoreThreshold px (default 80) of the bottom.

Showing 30 / 200

Item 1
Item 2
Item 3
Item 4

Props

PropTypeDefaultDescription
itemsT[]Array of items to render.
itemHeightnumber | "dynamic"Fixed height in px, or "dynamic" for content-driven heights.
estimatedItemHeightnumber40Initial height estimate used in dynamic mode.
heightnumber | string"100%"Container height.
overscannumber3Extra items rendered outside the visible area.
getItemKey(item, index) => string | numberindexReturns a stable key for each item.
children(item, index, style) => ReactNodeRender function. Must apply style to the item root element.
hasMorebooleanfalseWhether more items can be loaded.
loadingMorebooleanfalseShows a loading indicator at the bottom while true.
onLoadMore() => voidCalled when scroll reaches the load-more threshold.
loadMoreThresholdnumber80Px from bottom that triggers onLoadMore.
renderLoadingMoreReactNode"Loading more…"Custom content shown while loadingMore is true.
onScroll(scrollTop: number) => voidFires on scroll with the current scrollTop value.
onRangeChange(start, end) => voidFires when the visible index range changes.
stickyHeaderReactNodeHeader rendered inside the scroll container with position: sticky. Only shown when stickyHeaderHeight is greater than 0.
stickyHeaderHeightnumber0Height of stickyHeader. Subtracted from visible-area calculations so items don't render under it.
classNamestringExtra classes on the container.