Data
VirtualScroller
Renders only the items near the viewport, so a hundred thousand rows cost what a screenful does, with lazy loading.
WAI-ARIA tested
Import
main.ts
import { VirtualScroller } from '@vitral/vue';A hundred thousand rows
Item #0
Item #1
Item #2
Item #3
Item #4
Item #5
Item #6
Item #7
Item #8
Item #9
Item #10
Horizontal
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Lazy
Row 0…
Row 1…
Row 2…
Row 3…
Row 4…
Row 5…
Row 6…
Row 7…
Row 8…
Row 9…
Row 10…
Loading…
API
Read from packages/vue/src/components/VirtualScroller/types.ts, so it says what the component actually accepts.
Props
| Name | Type | Description |
|---|---|---|
| items | any[] | Every item; only the ones near the viewport are rendered. |
| itemSize * | number | One item's height (or width, horizontally) in pixels. |
| orientation | 'vertical' | 'horizontal' | Scroll along `'vertical'` (the default) or `'horizontal'`. |
| scrollHeight | string | The container's height (or width), when its parent does not set one. |
| scrollWidth | string | — |
| numToleratedItems | number | Items rendered past each edge of the viewport. Defaults to half a viewport. |
| lazy | boolean | Ask for items as they come into view (`lazy-load`) instead of having them all. |
| loading | boolean | Show the loader over the list. |
| disabled | boolean | Render every item, as a plain container would. |
| delay | number | Milliseconds to wait after scrolling stops before `lazy-load`. Defaults to 0. |
| dataKey | string | A key field for the rendered items; their index is used without one. |
Plus pt, dt and unstyled from BaseProps, see pass-through and unstyled mode.
Emits
| Event | Payload | Description |
|---|---|---|
| scroll-index-change | event: { first: number; last: number } | — |
| lazy-load | event: { first: number; last: number } | In lazy mode, the range of items the scroller is about to show. |
| scroll | event: Event | — |
Slots
| Name | Slot props | Description |
|---|---|---|
| item | (props: { item: unknown; options: VirtualScrollerItemOptions }) | — |
| content | (props: { items: unknown[]; first: number; last: number; styleOffset: Record<string, string>; itemSize: number }) | Replaces the rendered range entirely, for a table body, say. `styleOffset` places it. |
| loader | — | — |