"use client";
import { VirtualList } from "@pixxl-tools/components";| Prop | Type | Default | Description |
|---|---|---|---|
items (required) | readonly Item[] | — | Items to render. |
renderItem (required) | (item: Item, state: VirtualListItemState) => ReactNode | — | Row content. |
height | number | string | 20rem | Max height of the scroll container (default 20rem). |
itemHeight | VirtualItemSize | 40 | Row size in px, or an estimate per index with measure (default 40). |
label | string | — | Accessible name of the list. |
activeIndex | number | — | Active row (arrows, Page Up/Down, Home/End). |
defaultActiveIndex | number | — | Active row (arrows, Page Up/Down, Home/End). |
emptyState | ReactNode | — | Shown instead of the list when items is empty. |
getItemKey | (item: Item, index: number) => Key | — | Stable keys (and measurement cache keys). |
getItemLabel | (item: Item, index: number) => string | — | Short accessible name of a row (e.g. its title) instead of all its text. |
itemsrequiredreadonly Item[]
Items to render.
renderItemrequired(item: Item, state: VirtualListItemState) => ReactNode
Row content.
heightdefault 20remnumber | string
Max height of the scroll container (default 20rem).
itemHeightdefault 40VirtualItemSize
Row size in px, or an estimate per index with measure (default 40).
labelstring
Accessible name of the list.
activeIndexnumber
Active row (arrows, Page Up/Down, Home/End).
defaultActiveIndexnumber
Active row (arrows, Page Up/Down, Home/End).
emptyStateReactNode
Shown instead of the list when items is empty.
getItemKey(item: Item, index: number) => Key
Stable keys (and measurement cache keys).
getItemLabel(item: Item, index: number) => string
Short accessible name of a row (e.g. its title) instead of all its text.
Other props are passed to the root element (HTMLAttributes<HTMLDivElement>), including className, style, id and aria-* attributes.
Sound 1
Sound 2
Sound 3
Sound 4
Sound 5
Sound 6
Sound 7
Sound 8
Sound 9
Sound 10
Sound 11
Sound 12
Sound 13
Sound 14
type Sound = { id: string; name: string };
const sounds: Sound[] = Array.from({ length: 1000 }, (_, index) => ({ id: String(index), name: `Sound ${index + 1}` }));
function SoundRow({ sound }: { sound: Sound }) {
return <span>{sound.name}</span>;
}
<VirtualList items={sounds} itemHeight={44} height={280} label="Sounds" renderItem={(sound, { active }) => <SoundRow sound={sound} />} />