Officina UI
Components

VirtualList

Virtualized list that renders only visible rows for large datasets.

VirtualList renders only the rows currently in view (powered by TanStack Virtual), so it stays fast with thousands of items. Provide a renderItem function and a fixed viewport height; tune estimateSize to your row height for smoother scrolling before measurement. Reach for it when a plain mapped list would mount too many DOM nodes.

Example

Preview
import { VirtualList } from '@officina/ui';

function BigList() {
  const items = Array.from({ length: 10000 }, (_, i) => `Row ${i + 1}`);
  return (
    <VirtualList
      items={items}
      height={360}
      estimateSize={44}
      renderItem={(item) => <div className="px-3 py-2">{item}</div>}
    />
  );
}

API

PropTypeDefaultDescription
items*T[]—Items to virtualize; only the visible window is rendered.
renderItem*(item: T, index: number) => ReactNode—Renders a single item for the given index.
classNamestring—Extra classes for the scroll container.
estimateSizenumber44Estimated row height in px, used before measurement. Defaults to `44`.
heightstring | number360Height of the scroll viewport (px or CSS length).

On this page