Virtual List

Windowed list rendering using a shared height-delta index, with measured dynamic row heights.

Virtual List

Dynamic height

s-virtual-list only mounts rows near the viewport. It measures each rendered row, so wrapped text, expand/collapse state, and appended content retain correct offsets and scroll anchoring. Set retain-max-size when alternate virtual windows can expose taller content for the same stable item key.

Large generated lists compress the native scroll track when their total row height exceeds browser layout limits. scrollToIndex still uses the original item index, and scrollToOffset uses logical content pixels. Wheel movement keeps its normal pixel step, while dragging the native thumb navigates the full range.

Dynamic container safety

Percentage, flex, and grid layouts can resize or briefly lose a definite height. The viewport uses size containment with a 320px intrinsic fallback so its spacer cannot expand its own viewport. Once a parent height resolves, the viewport follows it automatically; this is not a permanent height lock. A hidden 0px container remains hidden and is remeasured when shown.

max-rendered-items limits mounted rows immediately, including excessive overscan, while keeping the current scroll position inside the rendered window. If the limit persists for 200ms in a visible container, development builds warn once per episode with layout and configuration suggestions. Transient spikes, hidden containers, and unmounted lists do not emit that warning. The mounting limit also applies in production.

This example switches between an unresolved parent, two definite heights, and a hidden container without creating a hundred-thousand-item array. Intentional dense layouts can increase the budget; the limit does not replace correct parent sizing. In flex/grid layouts, ensure the intended scrolling child can shrink, for example with min-height: 0.

API

PROPS

Property
Type
Values
Description
default
Example
More
max-rendered-items
Number
positive integer
Maximum simultaneously mounted rows including overscan. A sustained limit triggers a development warning; normal rendering resumes automatically when layout or overscan recovers. Increase this only for an intentionally dense viewport.
500
overscan
Number
item count
Render this many extra rows before and after the visible range.
5
—
items
Array
unknown[]
Source data rendered by the virtual list.
[]
height
Number | String
CSS height
Scroll viewport height. Unresolved percentage or auto layouts use a 320px intrinsic fallback and follow the parent again when its size resolves.
320
estimate-size
Number
pixels
Initial estimate before a row is measured. Use a realistic upper estimate for dynamic rows.
48
dynamic
Boolean
true | false
Measure every rendered row and support dynamic heights.
true
retain-max-size
Boolean
true | false
Retain the largest measured size for every stable item key, useful when different virtual windows reveal different content.
false
item-key
Function
(itemindex) => string | number
Stable unique row key. Required when data can reorder or append.
index

EVENTS

Event
Type
Description
default
Example
More
range-change
—
Fires when rendered virtual row range changes.
—
—
scroll
—
Native scroll event from the viewport.
—
—

EXPOSES

Method
Type
Description
default
Example
More
scrollToIndex
—
Scroll programmatically or reset all dynamic row measurements.
—
—
scrollToOffset
—
Scroll programmatically or reset all dynamic row measurements.
—
—
scrollBy
(delta: number) => void
Scroll by a relative distance in logical pixels. Positive values move down and negative values move up, including generated lists with compressed scrollbar tracks.
—
—
measure
—
Measure rendered rows, preserving the largest recorded height when retain-max-size is enabled.
—
—
resetMeasurements
() => Promise<void>
Clear recorded heights and measure the current layout again while retaining the visible row anchor. Call after changes to column widths or content that can reduce row heights.
—
—
Last Updated: 2026-10-28, 06:17:56 UTC
Copied