VirtualList
Data Display

VirtualList

Renders only the rows inside the viewport. A 100k-row list costs about as much as a 40-row one.

Component behavior

VirtualList renders rows near the viewport and an overscan margin. Row heights must be fixed or supplied by an index-based function.

Use cases
  • Large lists requiring row virtualization.
  • Growing log or event streams.
  • Lists with fixed or index-derived row heights.
Alternatives

List: the row count is small and bounded.

DataGrid: the view requires columns, sorting, and selection.

LogViewer: the task is specifically log display and filtering.

Props

VirtualListProps<T> props
PropTypeDefaultDescription
itemsT[]—Array of items to render.
itemHeightnumber | ((index: number) => number)—Fixed px height or a per-index function for variable rows.
renderItem(item: T, index: number) => ReactNode—Render function for each item.
heightnumber | string320Container height in px or any CSS length.
overscannumber6Rows rendered beyond each edge to cover fast scrolls.
getKey(item: T, index: number) => string | number—Stable key per row. Defaults to index.
onEndReached() => void—Called when the last row enters the viewport. Use to request additional data.
endThresholdnumber120Px from the bottom that counts as reached.
emptyStateReactNode—Shown when items is empty.
classNamestring—Additional CSS class.
styleCSSProperties—Inline style on the viewport element.
scrollToIndexnumber—Scrolls this index into view when it changes.

Examples

VirtualList with 500 items
ImportTSX
import { VirtualList } from "@solarius/onset";