Skip to content

VirtualScroller ​

Windowed list for long data

A list too long to render at once — thousands of log lines, a big contact list. It renders only what's in view. Under a few hundred rows, a plain list is simpler and works with find-in-page.

Basic
1第1話1,000
2第2話8,919
3第3話7,838
4第4話6,757
5第5話5,676
50,000 rows, ~12 in the DOM
Dynamic heights

#1

lorem ipsum

#2

lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum

#3

lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum

#4

lorem ipsum lorem ipsum lorem ipsum lorem ipsum

#5

lorem ipsum lorem ipsum

rows of different heights — measured as they render, `itemHeight` is only the estimate
  • Each row tells screen readers the real length and its position ("12 of 10,000"), though only a window is in the page.
  • itemHeight is exact; with dynamic it's an estimate and each row is measured. scrollTo(index) jumps to a row.
  • Find-in-page can't see rows that aren't rendered; give long lists a search of their own.

Usage ​

ts
import { BlessVirtualScroller } from "blessing-ui";

API ​

Props

NameTypeDefaultDescription
items*T[]—
itemHeight*number—row height in px — exact when `dynamic` is off, an estimate for unmeasured rows when it's on
dynamicbooleanfalsemeasure each rendered row (ResizeObserver) and lay out by real heights
heightstring"320px"
overscannumber4rows rendered beyond the viewport on each side
rowKey((item: T, index: number) => string | number)—
labelstring—

Slots

NameScopeDescription
default{ item: T; index: number; }

Released under the MIT License. Character names and artwork belong to their owners.