VirtualList
input
VirtualList: a scroll-virtualized list widget
Terminal
$termuijs render virtual-list
Installation
$ bunx termuijs add virtual-list
Copies the source into src/components/virtual-list/ and installs @termuijs/core, @termuijs/widgets.
Usage
ts
import { VirtualList } from '@termuijs/widgets'ts
new VirtualList(options: VirtualListOptions)API Reference
VirtualList
| Prop | Type | Required | Description |
|---|---|---|---|
totalItems | number | required | Total number of items (the full dataset size) |
itemHeight | number | optional | Height of each item in rows (default: 1) |
fixedItemHeight | number | optional | Fixed height of each item, alias for itemHeight |
memoizeLayout | boolean | optional | Whether to memoize the layout and bypass Flexbox recalculation on scroll frames (default: true) |
renderItem | (index: number) => string | required | Render function: returns the string content for an item at a given index |
style | Partial<Style> | optional | Style overrides |
onSelect | (index: number) => void | optional | Callback when an item is selected (Enter key) |
overscan | number | optional | Number of overscan rows to render above/below the viewport (default: 2) |
showScrollbar | boolean | optional | Show scrollbar (default: true) |
springScroll | boolean | optional | Enable spring scroll animations (default: true, respects prefersReducedMotion) |