Virtual List
A virtualized list separating a stable logical key sequence from bounded viewport item rendering.
Decouples a complete logical key sequence (itemKeys) from physical view nodes so application content is created and reused only for the visible range plus overscan, including variable-height rows.
Preview
Section titled “Preview” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
Installation
Section titled “Installation”Available starting in 0.3.0-rc.1 and later releases.
Compose Root, Viewport, and Content:
- Logical model and Web materialization:
RootmanagesitemKeys, item-countoverscanItems,maxMaterializedItems, revisions, and generation-bound commits. On Web,attachWebVirtualListfrom@proto.ui/prototypes-base/virtual-list/webmeasures variable item sizes, maintains spacer elements and keyed DOM views, supports scrolling to a key, and cleans up observers on dispose. - Single materializer lease: Each logical collection holds at most one active materializer lease.
attachWebVirtualListacquires the lease before attaching spacers, rows, or listeners; attaching a second host fails without disturbing the active one, so dispose the existing host before attaching a replacement. Custom hosts can acquire a lease viaacquireMaterializer(onRetired)(Web callers do not need to call it separately aroundattachWebVirtualList). - Retirement and retry: Unmounting or disposing
Rootretires the active materializer—invalidating in-flight generations, cleaning up views and observers, and ensuring late refresh, scroll, measurement, or duplicate dispose calls from a retired host cannot revoke a newer replacement. If initial rendering or observer setup fails, the lease is released so the collection can be retried.
| Prop | Type | Default |
|---|---|---|
itemKeys | readonly string[] | [] |
overscanItems | number | 2 |
maxMaterializedItems | number | 100 |
a11yLabel | string | Virtual list |
Viewport and Content take no props.