Skip to content
Thrum

Virtual list

A list of thousands of rows that keeps only the rows in view in the page, so it scrolls as smoothly at 100,000 rows as at 100. Rows can share one height or be measured, and a heading can pin each group to the top. For a few hundred rows a plain list or a paginated table is simpler.

Install

npx shadcn@latest add @thrum-pro/virtual-list

This is a Pro component. The command works once your project has a licence key: set up Pro or see pricing.

Data shape

Type
type VirtualListItem = {
  id: string;
  label: string;
  description?: string;
  meta?: string;
  group?: string;
};
Sample
const contacts: VirtualListItem[] = [
  { id: "c1", label: "Ada Abbott", meta: "#1", group: "A" },
  { id: "c2", label: "Ada Baker", description: "Prefers email.", meta: "#2", group: "A" },
  { id: "c3", label: "Ben Chen", meta: "#3", group: "B" },
];

Props

PropTypeDefaultDescription
itemsreadonly VirtualListItem[]RequiredEvery item. Only those in view, plus the overscan and the focused row, are in the page.
aria-labelstring–The list's name. Or point aria-labelledby at a visible heading.
rowHeightnumberDefault 40The height of a row in pixels. With measure it is the first guess and the smallest height.
measurebooleanDefault falseRows differ in height: each one is measured once drawn, and the list corrects its guesses as you scroll.
overscannumberDefault 6Rows drawn beyond each edge of the view, so a fast scroll does not show a gap.
stickyGroupsbooleanDefault falseStart each run of one group with a heading, and pin the current group's heading to the top.
valuestring | null–The selected id, when the parent holds it.
defaultValuestring | nullDefault nullThe id selected at first, when the list holds it itself.
onValueChange(id: string) => void–Called with the id of the row picked by a click, Enter or Space.
scrollToIndexnumber–Scroll so this item, counted from 0, is at the top, with its heading. It scrolls again whenever the number changes.
onRangeChange(range: { start: number; end: number; rendered: number }) => void–Called when the drawn rows change: the first and last item drawn, and how many item rows are in the page.
emptyLabelstringDefault "No items"Shown when there are no items.
soundbooleanDefault truePlay a click when a row is picked, if the visitor has sound on.
classNamestring–Classes for the frame. Set the height here: the default is h-80, 320 pixels.
layoutRows(), rowAt(), visibleRange()functions–More exports: the offsets of rows from their heights, the row under a point, and the rows to draw for a view.

Motion and sound

Motion

  • Nothing animates: the rows move with the scroll and nothing else.
  • A row's shade changes at once under the pointer.

Sound

  • A click when a different row is picked.

Sound is off until the visitor turns it on. Pass sound={false} to keep this component silent. How sound works

Accessibility

  • It follows the WAI-ARIA listbox pattern: the scrolling box is the listbox and holds the focus; aria-activedescendant points at the outlined row.
  • Every drawn row carries aria-setsize with the whole length and aria-posinset with its place, so a screen reader says 4,213 of 10,000 although only a few rows exist.
  • The outlined row stays in the page even after it scrolls far out of view, so the active descendant always exists.
  • The selected row is shaded, set in medium weight and marked by a bar at its start, and carries aria-selected.
  • Group headings are drawn for the eye and hidden from screen readers; each row says its group at the end of its name instead.
  • The list frame is a panel surface (data-surface="panel"): under a glass material it becomes translucent while keeping row text and group headings readable.
KeysAction
TabFocus the list. The row last moved to is outlined.
↓ / ↑Move to the next or previous row, scrolling just enough to show it.
Page Down / Page UpMove by one view's worth of rows.
Home / EndMove to the first or the last row, 10,000 rows away or more.
Enter / SpacePick the outlined row.

Source

SourcePro

The source comes with Pro

TypeScript source · Copy-paste ready · MIT-compatible for client projects · Includes all dependencies

Files and dependencies

Adds
components/ui/virtual-list.tsx
Packages
None
Brings along
Sound engine

Changelog

  1. 1.0.0 · 2026-12-03First release.

Loading index…

Keyboard shortcuts

/Ctrl KSearch components, docs and actions
?Show this list
AAppearance studio
SSound on or off
MFull or reduced motion
TTheme: auto, light, dark
GSurface: solid or frosted
BBackdrop photograph (under glass)
CCorner radius: square to round
RReplay the demo, on a component page
DDraw new data, on a component page
←→HomeEndMove the cursor in a focused chart
EscClose a dialog, or leave a chart cursor