Skip to content

Virtual List

Data displaySince 0.13.0

Renders only the visible items, plus an overscan, of very large lists: 100,000 items and more, with fixed or measured variable heights. A selectable list is a WAI-ARIA listbox with single or multiple selection, type-ahead, and roving focus; otherwise it is a plain role="list". The focused item always stays rendered, so focus is never lost while scrolling. aui-range-change reports the visible range for lazy loading, and the optional loadMore hook adds infinite scroll with a polite status message. Tree View, Command Palette, Transfer List, and File Manager build on the same windowing engine.

  • 100,000+ itemsOnly the visible items and an overscan are in the DOM; offsets use typed arrays and binary search.
  • Fixed or measured heightsA fixed item height, or measured variable heights that keep the visible content anchored.
  • Listbox selectionSingle or multiple selection with Shift ranges, Ctrl+A, type-ahead, and a roving tab stop.
  • Focus never lostThe focused item stays rendered while you scroll away, so keyboard users keep their place.
  • Lazy and infiniteaui-range-change reports the visible range; loadMore appends pages with a polite status.

Use it for

  • Lists of hundreds to millions of items, such as people, files, or log lines.
  • A selectable list in a sidebar or picker that must stay fast with large data.
  • Infinite scroll over a paged API.

Use something else for

  • Short lists (under a few hundred items): render them directly or use Sortable List.
  • Tabular data with columns, sorting, and filters: use Data Table or Data Grid (both virtualize).
  • Lists the user must print or search with the browser’s find: only visible items are in the DOM.
Anatomy
<div class="aui-virtual-list aui-virtual-list--selectable">
<div class="aui-virtual-list__viewport" role="listbox" aria-label="Employees" aria-multiselectable="true"> (scroll container)
<div class="aui-virtual-list__canvas" role="none"> (full height of all items)
<div class="aui-virtual-list__item" role="option" aria-selected="false" aria-posinset="41" aria-setsize="10000" tabindex="-1">renderItem()</div>
<div class="aui-virtual-list__item aui-virtual-list__item--active" role="option" aria-selected="true" tabindex="0">...</div>
</div>
</div>
<div class="aui-virtual-list__empty" hidden>No items</div>
<div class="aui-virtual-list__status" role="status">Loading more items</div>
</div>

Use the bar above each frame to switch theme, density, direction, and locale.

Virtual List in the Workspace layout showcase

Section titled “Virtual List in the Workspace layout showcase”

The part of the Workspace layout showcase that uses Virtual List. Change its options, use it with the keyboard, and watch the event log; the link in the frame opens the full showcase. The bar above the frame switches theme, density, direction, and locale.

Showcase source
// Workspace layout showcase: a splitter with a virtual list of 10,000 employees in the
// sidebar and the selected person's details beside it. Empty states appear when nothing is
// selected and when the department filter matches nobody.
import { EmptyState } from '@absoluteui/components/empty-state';
import { Splitter, type SplitterChangeDetail } from '@absoluteui/components/splitter';
import { VirtualList, type VirtualListChangeDetail, type VirtualListRangeChangeDetail } from '@absoluteui/components/virtual-list';
import { action, choice, createShowcase, section, status, toggle } from './kit.js';
const sc = createShowcase({
title: 'Workspace layout',
description: 'Resize or collapse the sidebar, scroll and select among 10,000 employees with the mouse or keyboard (arrows, Home, End, type-ahead), and filter to see the empty states.',
});
interface Employee {
id: string;
name: string;
title: string;
department: string;
location: string;
}
const FIRST = ['Ada', 'Grace', 'Alan', 'Katherine', 'Edsger', 'Barbara', 'Donald', 'Margaret', 'Tim', 'Radia', 'Linus', 'Frances'];
const LAST = ['Lovelace', 'Hopper', 'Turing', 'Johnson', 'Dijkstra', 'Liskov', 'Knuth', 'Hamilton', 'Berners-Lee', 'Perlman', 'Torvalds', 'Allen'];
const DEPARTMENTS = ['Engineering', 'Finance', 'Marketing', 'People', 'Sales'];
const TITLES = ['Analyst', 'Engineer', 'Manager', 'Specialist', 'Lead'];
const LOCATIONS = ['Berlin', 'Chennai', 'London', 'New York', 'Sydney'];
const pick = (list: readonly string[], i: number): string => list[i % list.length] ?? '';
const EMPLOYEES: Employee[] = Array.from({ length: 10_000 }, (_, i) => ({
id: `E${String(i + 1).padStart(5, '0')}`,
name: `${pick(LAST, Math.floor(i / FIRST.length))}, ${pick(FIRST, i)}`,
title: pick(TITLES, i * 7),
department: pick(DEPARTMENTS, i * 3),
location: pick(LOCATIONS, i * 11),
})).sort((a, b) => a.name.localeCompare(b.name) || a.id.localeCompare(b.id));
function row(e: Employee): Node {
const el = document.createElement('div');
el.className = 'sc-person';
const name = document.createElement('span');
name.className = 'sc-person__name';
name.textContent = e.name;
const meta = document.createElement('span');
meta.className = 'sc-person__meta';
meta.textContent = `${e.title}, ${e.department}`;
el.append(name, meta);
return el;
}
const area = section(sc, 'Employees', ['splitter', 'virtual-list', 'empty-state']);
const range = status(area);
const workspace = document.createElement('div');
workspace.className = 'sc-workspace';
area.append(workspace);
// The list's own empty content: shown when the filter matches nobody.
const noMatchHost = document.createElement('div');
const noMatch = EmptyState.create(noMatchHost, {
title: 'No employees in this department',
description: 'Choose another department or show everyone.',
icon: 'search',
size: 'sm',
headingLevel: null,
live: true,
primaryAction: { label: 'Show all departments' },
});
const listHost = document.createElement('div');
listHost.className = 'sc-workspace__list';
let visible = EMPLOYEES;
const list = VirtualList.create<Employee>(listHost, {
label: 'Employees',
items: visible,
height: null,
selection: 'single',
itemKey: (e) => e.id,
itemText: (e) => e.name,
itemHeight: 56,
empty: noMatchHost,
renderItem: row,
});
const detail = document.createElement('div');
detail.className = 'sc-workspace__detail';
const emptyHost = document.createElement('div');
const nothingSelected = EmptyState.create(emptyHost, {
title: 'No employee selected',
description: 'Select someone in the list to see their details.',
icon: 'search',
headingLevel: 3,
});
const card = document.createElement('section');
card.className = 'sc-workspace__card';
card.hidden = true;
detail.append(emptyHost, card);
const splitter = Splitter.create(workspace, {
panes: [
{ content: listHost, label: 'Employees', size: '38%', min: 200, max: '70%', collapsible: true },
{ content: detail, label: 'Details', min: 240 },
],
});
sc.listen(splitter.host, ['aui-change'], 'splitter');
const byId = new Map(EMPLOYEES.map((e) => [e.id, e]));
function showDetails(keys: readonly string[]): void {
const people = keys.map((k) => byId.get(k)).filter((e): e is Employee => e !== undefined);
emptyHost.hidden = people.length > 0;
card.hidden = people.length === 0;
if (people.length === 0) return;
const [first] = people;
if (people.length > 1 || !first) {
const h = document.createElement('h3');
h.textContent = `${String(people.length)} employees selected`;
const p = document.createElement('p');
p.textContent = people.slice(0, 5).map((e) => e.name).join('; ') + (people.length > 5 ? '; ...' : '');
card.replaceChildren(h, p);
return;
}
const h = document.createElement('h3');
h.textContent = first.name;
const dl = document.createElement('dl');
for (const [term, value] of [['Employee ID', first.id], ['Title', first.title], ['Department', first.department], ['Location', first.location]] as const) {
const dt = document.createElement('dt');
dt.textContent = term;
const dd = document.createElement('dd');
dd.textContent = value;
dl.append(dt, dd);
}
card.replaceChildren(h, dl);
}
list.host.addEventListener('aui-change', (e) => {
const d = (e as CustomEvent<VirtualListChangeDetail>).detail;
showDetails(d.value);
sc.log('list aui-change', d);
});
const showRange = (start: number, end: number): void => {
range.textContent = visible.length === 0 ? 'No employees shown.' : `Showing ${String(start + 1)} to ${String(end)} of ${visible.length.toLocaleString('en-US')} employees.`;
};
showRange(list.range.start, list.range.end);
list.host.addEventListener('aui-range-change', (e) => {
const d = (e as CustomEvent<VirtualListRangeChangeDetail>).detail;
showRange(d.start, d.end);
});
splitter.host.addEventListener('aui-change', (e) => {
// Change events of the components inside the panes bubble through the splitter too.
if (e.target !== splitter.host) return;
const d = (e as CustomEvent<SplitterChangeDetail>).detail;
range.dataset.sizes = d.sizes.join(',');
});
const filterBy = (value: string): void => {
visible = value === 'all' ? EMPLOYEES : EMPLOYEES.filter((e) => e.department === value);
list.update({ items: visible });
list.scrollToIndex(0, 'start');
showRange(list.range.start, list.range.end);
};
const departmentChoice = choice(
sc,
'Department',
[
{ value: 'all', label: 'All departments' },
...DEPARTMENTS.map((d) => ({ value: d, label: d })),
{ value: 'Legal', label: 'Legal (no one)' },
],
'all',
filterBy,
['virtual-list', 'empty-state'],
);
noMatchHost.addEventListener('aui-action', () => {
departmentChoice.setValue('all');
filterBy('all');
sc.log('empty-state aui-action', { action: 'primary' });
});
toggle(sc, 'Multiple selection', false, (multiple) => {
list.update({ selection: multiple ? 'multiple' : 'single', value: [] });
showDetails([]);
}, ['virtual-list']);
toggle(sc, 'Selection follows focus', false, (selectionFollowsFocus) => {
list.update({ selectionFollowsFocus });
}, ['virtual-list']);
choice(
sc,
'Layout',
[
{ value: 'horizontal', label: 'Side by side' },
{ value: 'vertical', label: 'Stacked' },
],
'horizontal',
(orientation) => {
splitter.update({ orientation });
},
['splitter'],
);
action(sc, 'Collapse or restore sidebar', () => {
if (splitter.collapsed[0]) splitter.expand(0);
else splitter.collapse(0);
}, ['splitter']);
action(sc, 'Jump to the middle', () => {
list.scrollToIndex(Math.floor(visible.length / 2), 'center');
}, ['virtual-list']);
action(sc, 'Clear selection', () => {
list.setValue([]);
showDetails([]);
}, ['virtual-list']);
toggle(sc, 'Compact empty states', false, (compact) => {
nothingSelected.update({ size: compact ? 'sm' : 'md' });
noMatch.update({ size: compact ? 'sm' : 'md' });
}, ['empty-state']);
import { VirtualList, type VirtualListChangeDetail } from '@absoluteui/components/virtual-list';
interface Person { id: string; name: string }
const people: Person[] = Array.from({ length: 100_000 }, (_, i) => ({ id: `p${String(i)}`, name: `Person ${String(i + 1)}` }));
const host = document.createElement('div');
document.body.append(host);
const list = VirtualList.create<Person>(host, {
label: 'People',
items: people,
selection: 'multiple',
itemKey: (p) => p.id,
itemText: (p) => p.name,
renderItem: (p) => document.createTextNode(p.name),
});
host.addEventListener('aui-change', (event) => {
const { value } = (event as CustomEvent<VirtualListChangeDetail>).detail;
host.dataset.selected = String(value.length);
});
list.scrollToIndex(5000, 'center');
import { VirtualList } from '@absoluteui/components/virtual-list';
const host = document.createElement('div');
document.body.append(host);
let items: string[] = [];
const list = VirtualList.create<string>(host, {
label: 'Activity',
items,
variableHeight: true,
renderItem: (text) => {
const p = document.createElement('p');
p.textContent = text;
return p;
},
loadMore: async () => {
const page = await Promise.resolve(Array.from({ length: 50 }, (_, i) => `Event ${String(items.length + i + 1)}`));
items = [...items, ...page];
list.update({ items, hasMore: items.length < 500 });
},
});
Terminal window
npm install @absoluteui/components @absoluteui/core @absoluteui/theme

Registry setup, the theme stylesheet, and the Content Security Policy are covered in Installation.

import { VirtualList } from '@absoluteui/components/virtual-list';
import '@absoluteui/components/virtual-list/style.css';
import { VirtualList } from '@absoluteui/components/virtual-list';
import '@absoluteui/components/virtual-list/style.css';
const host = document.querySelector<HTMLElement>('#countries');
if (host) VirtualList.create<string>(host, { label: 'Countries', items: ['Austria', 'Belgium', 'Chile'], selection: 'single', renderItem: (name) => document.createTextNode(name) });
More usage
import { VirtualList, type VirtualListRangeChangeDetail } from '@absoluteui/components/virtual-list';
const host = document.querySelector<HTMLElement>('#log');
if (host) {
const lines = Array.from({ length: 250_000 }, (_, i) => `Line ${String(i + 1)}`);
VirtualList.create<string>(host, { label: 'Build log', items: lines, renderItem: (line) => document.createTextNode(line) });
host.addEventListener('aui-range-change', (event) => {
const { start, end } = (event as CustomEvent<VirtualListRangeChangeDetail>).detail;
host.dataset.visible = `${String(start + 1)}-${String(end)}`;
});
}

Using Angular? See Virtual List for Angular.

VirtualList.create<Item>(host: HTMLElement, options: VirtualListOptions<Item>): VirtualList<Item>

Global configuration key: virtualList (see Configuration).

Option Type Default Description
label string Accessible name of the list. Required.
items readonly Item[] The items (up to 1,000,000; the total height must stay under the browser limit, about 17.9 million px in Firefox); only the visible ones are rendered. Required.
renderItem (item: Item, index: number) => Node Content of one item; called whenever the item is rendered. Required.
itemKey (item: Item, index: number) => string Stable key per item, used by value. Default: the index.
itemText (item: Item, index: number) => string Type-ahead text. Default: strings, numbers, or the item’s label property.
itemHeight number Item height in pixels (the estimate with variableHeight). Default by density: 32, 40, or 48.
variableHeight boolean "false" Measure every rendered item instead of a fixed height.
height string | null "20rem" Block size of the scroll area as a CSS length, or null to fill the host.
selection 'none' | 'single' | 'multiple' "none" none renders a plain list; single and multiple render a listbox.
value readonly string[] "[]" Keys of the selected items.
selectionFollowsFocus boolean "false" Single selection: moving focus with the keyboard also selects.
isDisabled (item: Item, index: number) => boolean Items that cannot be selected or focused.
empty Node | string Shown instead of the list when there are no items (for example an Empty State host).
loadMore (() => Promise<void> | void) | null Infinite scroll: called near the end; resolve after appending items with update({ items }).
hasMore boolean "true" More items can be loaded (with loadMore).
loadMoreThreshold number "10" Items from the end at which loading starts.
overscan number "5" Items rendered beyond each edge of the visible area (0 to 100). Globally configurable.
locale string "en-US" Locale of the status messages. Globally configurable. Inherited from common configuration.
density 'compact' | 'comfortable' | 'spacious' "comfortable" Default item height when itemHeight is not set. Globally configurable. Inherited from common configuration.
Property Type Description
host HTMLElement The host element.
value readonly string[] Keys of the selected items.
range WindowRange The visible items { start, end } (end exclusive).
activeIndex number Index of the focusable item in a listbox, or -1.
options Readonly<VirtualListOptions<Item>> Current options.
Method Description
scrollToIndex(index: number, align?: 'auto' | 'start' | 'center' | 'end'): void Scroll so the item is visible (auto: only as far as needed).
focusItem(index: number): void Focus an item of a listbox, scrolling it into view.
getItemElement(index: number): HTMLElement | null The rendered element of an item, or null.
setValue(value: readonly string[]): void Select by keys (no event).
refresh(): void Render the visible items again after item objects changed in place.
update(options: Partial<VirtualListOptions<Item>>): void Merge and apply options.
destroy(): void Remove rendering, observers, and listeners.
Event Detail Bubbles Cancelable Description
aui-change VirtualListChangeDetail Yes No The user changed the selection: { value, index }.
aui-range-change VirtualListRangeChangeDetail Yes No The visible range changed: { start, end, renderedStart, renderedEnd } (for lazy loading).
Area Description
renderItem Each item’s content (a Node).
empty Content shown when there are no items.

All rules live in the aui.components cascade layer, so application styles override them without specificity battles.

Class Purpose
aui-virtual-list Host.
aui-virtual-list--selectable | --variable | --fill | --empty Listbox mode, measured heights, fill the host, no items.
aui-virtual-list__viewport Scroll container (role=list or listbox).
aui-virtual-list__canvas Full-height positioning layer (role=none).
aui-virtual-list__item | __item--selected | __item--active A rendered item (role=listitem or option), selected, and the focusable one.
aui-virtual-list__empty Empty content.
aui-virtual-list__status | __status--visible | __status--error Load-more status (role=status).

Tokens this stylesheet reads (verified in CI). Override them in a theme or with the Theme Designer.

--aui-border-width | --aui-color-border | --aui-color-error-fg | --aui-color-focus-ring | --aui-color-hover | --aui-color-selected | --aui-color-selected-indicator | --aui-color-selected-text | --aui-color-surface | --aui-color-text | --aui-color-text-disabled | --aui-color-text-muted | --aui-focus-ring-offset | --aui-focus-ring-width | --aui-font-family-sans | --aui-font-size-md | --aui-font-size-sm | --aui-line-height-normal | --aui-radius-md | --aui-radius-pill | --aui-space-1 | --aui-space-2 | --aui-space-3 | --aui-space-4

TypeScript definitions
type VirtualListSelection = 'none' | 'single' | 'multiple';
interface VirtualListConfig { overscan: number }
interface VirtualListOptions<Item = unknown> extends Partial<VirtualListConfig> {
label: string;
items: readonly Item[];
renderItem: (item: Item, index: number) => Node;
itemKey?: (item: Item, index: number) => string;
itemText?: (item: Item, index: number) => string;
itemHeight?: number;
variableHeight?: boolean;
height?: string | null;
selection?: VirtualListSelection;
value?: readonly string[];
selectionFollowsFocus?: boolean;
isDisabled?: (item: Item, index: number) => boolean;
empty?: Node | string;
loadMore?: (() => Promise<void> | void) | null;
hasMore?: boolean;
loadMoreThreshold?: number;
locale?: string;
density?: Density;
}
interface VirtualListChangeDetail { value: string[]; index: number }
interface VirtualListRangeChangeDetail { start: number; end: number; renderedStart: number; renderedEnd: number }
interface WindowRange { readonly start: number; readonly end: number }

Pattern: WAI-ARIA APG Listbox (single and multiple selection, roving focus, type-ahead) when selectable; a plain list (role=list) otherwise. Items carry aria-posinset and aria-setsize because only part of the list is rendered.

Checked on every docs build: the showcase passes axe (WCAG 2.2 A and AA rules) in the default, dark, and high-contrast themes and right to left; the playground loads without errors and passes axe before and after every on/off option is switched, with no Content Security Policy violations.

Key Context Action
Tab Listbox Focus the active item (one tab stop); a plain list focuses its scroll container.
Down / Up Listbox Next or previous enabled item.
Home / End Listbox First or last enabled item (scrolls far lists instantly).
Page Down / Page Up Listbox Move by one visible page.
Space / Enter Listbox Select the focused item (single) or toggle it (multiple).
Shift + Down / Up / Home / End / Space Multiple selection Select the range from the anchor to the focused item.
Ctrl + A (Cmd + A) Multiple selection Select all enabled items, or clear them when all are selected.
Printable characters Listbox Type-ahead to the next item whose text starts with the typed characters.
Arrow keys / Page keys Plain list Scroll the list (native scrolling).
Element Role
viewport listbox (selectable) or list
canvas none
item option (selectable) or listitem
status status
Attribute Element Value
aria-label viewport the label option
aria-multiselectable viewport true with multiple selection
aria-selected option true or false
aria-disabled option true for isDisabled items
aria-posinset / aria-setsize item position and total (-1 while more can be loaded)
aria-busy viewport true while loadMore runs

The focused item is always rendered, even when scrolled far away, so focus is never lost; Home, End, and type-ahead scroll the target into view before focusing it.

Criterion Level Note
1.3.1 Info and Relationships A
1.4.1 Use of Color A
1.4.11 Non-text Contrast AA
2.1.1 Keyboard A
2.4.3 Focus Order A
2.4.7 Focus Visible AA
4.1.2 Name, Role, Value A
4.1.3 Status Messages AA

Automated test results: Accessibility and compliance.

  • Selection is shown by a start-edge bar as well as color (WCAG 1.4.1).
  • Load progress and failures are announced politely through the status element (WCAG 4.1.3).
  • Screen readers count only rendered items when browsing by virtual cursor; aria-setsize gives the real total.
  • Manual screen-reader verification (NVDA, JAWS, VoiceOver) is pending.
Import cost Minified gzip brotli CSS brotli
@absoluteui/components/virtual-list 22.0 kB 8.3 kB 7.4 kB 0.9 kB

Measured at build time, including every AbsoluteUI module the component pulls in. No third-party runtime dependencies.

Budget (enforced in CI) Limit
VirtualList.create with 100,000 items < 20 ms average in headless Chromium
Rendered item elements at 100,000 items visible items + 2 x overscan + 1

Tested scale: 100,000 fixed-height and variable-height items; at most 1,000,000 items, and items x height must stay under the browser’s maximum element height (about 17.9 million px in Firefox, 33.5 million px in Chromium): 400,000 items of 40 px work everywhere.

Offsets are prefix sums in typed arrays, rebuilt lazily from the first changed size; lookups by scroll position are binary searches. Only visible + 2 x overscan + 1 item elements exist; elements are recycled as the window moves. Variable heights are measured once per rendering and observed for later changes, keeping the visible content anchored.

Measured run times: Performance.

States

Plain list; single or multiple selection; disabled items; variable heights; loading more; load failed; empty.

State transitions
From Trigger To
any scroll or resize new window rendered; aui-range-change when the visible range changed
near the end loadMore set and hasMore not false loading (status “Loading more items”, aria-busy), then loaded or failed
unselected click, Space, Enter selected; aui-change
items update({ items: [] }) empty content shown
Accessibility notes
  • The focused item always stays rendered, even when scrolled far away, so focus is never lost (WCAG 2.4.3).
  • Selection is shown by a start-edge bar as well as color (WCAG 1.4.1).
  • Loading progress and failures are announced politely (WCAG 4.1.3).
  • The e2e axe run covers three themes; manual screen-reader verification is pending.
Responsive behavior

Fills the inline size of its host; the block size comes from height, or from the host with height: null (for example a Splitter pane). The rendered window follows the viewport size.

Right-to-left

Items, text, and the selection bar follow the writing direction; the scrollbar sits where the browser places it.

Theming

Three themes through the role tokens; selected items stay legible in high contrast. Forced colors use Highlight, HighlightText, and GrayText.

Global configuration
configureAbsoluteUI({ components: { virtualList: { overscan: 10 } } });
Component configuration

Instance overscan, locale, and density override configuration; configuration changes lay out existing lists again.

Security

Items are DOM nodes built by the application’s renderItem; the component never parses HTML. Status messages are set as text.

Data handling

No persistence, network access, or telemetry. loadMore is the application’s own function.

Supported data scale

Tested with 100,000 fixed-height and variable-height items. The option limit is 1,000,000 items, and the total height (items x item height) must stay under the browser’s maximum element height: about 17.9 million px in Firefox and 33.5 million px in Chromium. 400,000 items of 40 px work in every supported browser.

Edge cases
  • update({ items }) keeps the scroll position, measured sizes of unchanged indexes, and selected keys (keys of removed items stay selected until setValue).
  • A loadMore that resolves without new items is not called again until the user scrolls.
  • With height: null, a host without a height renders an empty viewport; give the host a block size.
  • Single selection rejects more than one key in value.
Errors
Code Category Cause
VIRTUAL_LIST_OPTIONS configuration Blank label, items not an array or more than 1,000,000, a missing renderItem, an itemHeight outside 8 to 2000, a height that is not a CSS length, an unknown selection, or value with non-string keys.
CFG_INVALID_VALUE / CFG_UNKNOWN_OPTION configuration Invalid or unknown configuration.

Invalid options throw before the host is modified; an invalid update() leaves the previous state intact.

Known limitations
  • Vertical lists only.
  • The total height must stay under the browser’s maximum element height (section 26).
  • Only rendered items are in the DOM, so find-in-page and printing see only those.
  • Variable heights are estimated until an item has been rendered once.
  • Manual screen-reader verification is pending.
Unsupported scenarios
  • Horizontal or grid virtualization.
  • Drag-and-drop reordering (use Sortable List for short lists).