Props
All available props for the SvelteVirtualList component.
Required Props
items
The array of items to render.
items: TItem[]items: TItem[]renderItem
A Svelte snippet that defines how each item is rendered.
{#snippet renderItem(item, index)}
<div>{item.text}</div>
{/snippet}{#snippet renderItem(item, index)}
<div>{item.text}</div>
{/snippet}Optional Props
mode
Scroll direction mode.
| Value | Description |
|---|---|
'topToBottom' | Standard scrolling (default) |
'bottomToTop' | Chat-style, anchored at bottom |
mode?: 'topToBottom' | 'bottomToTop'
// Default: 'topToBottom'mode?: 'topToBottom' | 'bottomToTop'
// Default: 'topToBottom'bufferSize
Number of items to render outside the visible viewport for smooth scrolling.
bufferSize?: number
// Default: 20bufferSize?: number
// Default: 20defaultEstimatedItemHeight
Initial height estimate (in pixels) for items before measurement.
defaultEstimatedItemHeight?: number
// Default: 40defaultEstimatedItemHeight?: number
// Default: 40Infinite Scroll Props
onLoadMore
Callback triggered when scrolling near the end of the list.
onLoadMore?: () => void | Promise<void>onLoadMore?: () => void | Promise<void>loadMoreThreshold
Number of items from the end to trigger onLoadMore.
loadMoreThreshold?: number
// Default: 20loadMoreThreshold?: number
// Default: 20hasMore
Set to false when all data has been loaded.
hasMore?: boolean
// Default: truehasMore?: boolean
// Default: trueStyling Props
containerClass
CSS class for the outer container element.
containerClass?: stringcontainerClass?: stringviewportClass
CSS class for the scrollable viewport element.
viewportClass?: stringviewportClass?: stringcontentClass
CSS class for the content wrapper element.
contentClass?: stringcontentClass?: stringitemsClass
CSS class for the items wrapper element.
itemsClass?: stringitemsClass?: stringDebug Props
debug
Enable debug mode with visual overlay.
debug?: boolean
// Default: falsedebug?: boolean
// Default: falsedebugFunction
Custom callback to receive debug information.
debugFunction?: (info: SvelteVirtualListDebugInfo) => voiddebugFunction?: (info: SvelteVirtualListDebugInfo) => voidTesting Props
testId
Base test ID for component elements.
testId?: stringtestId?: stringWhen set, adds data-testid attributes:
{testId}-container{testId}-viewport{testId}-content{testId}-items