Data display
VirtualList
Free3.8 KB gzippedA list that renders only the items in view, so tens of thousands of rows scroll smoothly. Items may have any height (they're measured as they render). Built on useVirtualizer and ScrollArea.
Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · Keys: Tab, Arrow keys, Page Up and 1 more · Full report
Import
import { VirtualList } from "@vjdesigns/vjdesigns-ui";
Importing only VirtualList adds about 3.8 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.
Examples
Basic
Ten thousand rows, but only the ones in view are in the page. Screen readers still hear "item 4,812 of 10,000": each item carries aria-posinset and aria-setsize. The list is keyboard scrollable, and Tab keeps working through items' links and buttons.
import { Flex, Text, VirtualList } from "@vjdesigns/vjdesigns-ui";
const games = Array.from({ length: 10000 }, (_, i) => ({ id: i + 1, label: `Game ${i + 1}` }));
export function Basic() {
return (
<VirtualList
aria-label="Season games"
items={games}
getKey={(game) => game.id}
height="18rem"
style={{ width: "100%", maxWidth: "22rem" }}
renderItem={(game) => (
<Flex justify="between" style={{ padding: "0.75rem 1rem" }}>
<Text>{game.label}</Text>
<Text tone="muted">#{game.id}</Text>
</Flex>
)}
/>
);
}
Right to left
The first example again, inside a right-to-left LocaleProvider (Arabic). Layout, spacing and arrow icons mirror, and the components' built-in text is translated. The example's own text stays in English.
Basic
import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";
// Basic is the "Basic" example above.
<LocaleProvider locale="ar" messages={ar}>
<Basic />
</LocaleProvider>
Usage notes
Accessibility: a real role="list" whose items carry aria-setsize and aria-posinset, so screen readers announce "item 4,812 of 10,000" even though only a few dozen exist in the page. The scroll area is keyboard scrollable, and Tab through items' links and buttons keeps working (new items render as focus scrolls them into view). Browser find-in-page only sees rendered items, so offer search for long lists.
<VirtualList
aria-label="All players"
items={players}
height="24rem"
getKey={(p) => p.id}
renderItem={(p) => <PlayerRow player={p} />}
/>
API reference
VirtualList
New in 1.5.0| Prop | Type | Default |
|---|---|---|
itemsRequiredThe items. Only the ones in view (plus | readonly T[] | — |
renderItemRequiredRenders one item. Its height can vary; it is measured. | (item: T, index: number) => ReactNode | — |
getKeyStable key for an item. | (item: T, index: number) => string | number | its index |
estimateSizeEstimated item height in px (or a function of the index), used until an item is measured. | number | ((index: number) => number) | 48 |
heightRequiredHeight of the scrolling area (any CSS length, or px as a number). The list needs a height to virtualize. | CSSProperties["height"] | — |
overscanExtra items rendered above and below the view. | number | 6 |
gapSpace between items, in px. | number | 0 |
emptyStateShown instead of the list when | ReactNode | — |
aria-labelAccessible name of the list. Also names the scrolling region. | string | — |
aria-labelledbyId of a visible element that names the list. | string | — |
scrollbarSizeScrollbar thickness. | "sm""md" | "md" |
apiRefControls for scrolling to an item. | Ref<VirtualListApi> | — |
classNameClass name for the outer scroll area. | string | — |
itemClassNameClass name for each item wrapper. | string | — |
styleStyle for the outer scroll area. | CSSProperties | — |
See what changed in each version in the Changelog.
Accessibility report
VirtualList targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.
axe-core audit (live)
Checking the examples above…
Lighthouse audit
Light mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Dark mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.
Built-in behavior
Keyboard
| Key | Action |
|---|---|
| Tab | Moves into the list, then through items' links and buttons (new items render as focus reaches them). |
| Arrow keysPage UpPage Down | Scroll the list. |
Only items in view are in the page, so browser find-in-page sees only those; offer a search for long lists.
Roles and states
| Element | Role | States and properties |
|---|---|---|
| List | list | aria-label or aria-labelledby |
| Item | listitem | aria-posinset and aria-setsize, so position is read as "4,812 of 10,000" |
Manual checks
Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.
| Check | What to test | WCAG 2.2 |
|---|---|---|
| Keyboard | Every action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck. | 2.1.1 (A), 2.1.2 (A) |
| Focus | Focus moves in a logical order, is always visible, and isn't hidden behind sticky headers. | 2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA) |
| Screen readers | Names, roles and states are announced correctly, and status changes are announced without moving focus. | 1.3.1 (A), 4.1.2 (A), 4.1.3 (AA) |
| Color | Meaning never depends on color alone; your own colors meet contrast in both modes. | 1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA) |
| Zoom and reflow | At 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed. | 1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA) |
| Pointer targets | Click and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap. | 2.5.8 (AA), 2.5.5 (AAA) |
| Motion | Animations respect the reduced-motion setting. | 2.3.3 (AAA) |