Skip to content

VirtualList

widgetsinput

VirtualList: a scroll-virtualized list widget

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

PropTypeRequiredDescription
totalItemsnumberrequiredTotal number of items (the full dataset size)
itemHeightnumberoptionalHeight of each item in rows (default: 1)
fixedItemHeightnumberoptionalFixed height of each item, alias for itemHeight
memoizeLayoutbooleanoptionalWhether to memoize the layout and bypass Flexbox recalculation on scroll frames (default: true)
renderItem(index: number) => stringrequiredRender function: returns the string content for an item at a given index
stylePartial<Style>optionalStyle overrides
onSelect(index: number) => voidoptionalCallback when an item is selected (Enter key)
overscannumberoptionalNumber of overscan rows to render above/below the viewport (default: 2)
showScrollbarbooleanoptionalShow scrollbar (default: true)
springScrollbooleanoptionalEnable spring scroll animations (default: true, respects prefersReducedMotion)
#input#virtual-list