# VirtualList

> Fixed-height windowed list with overscan and explicit assistive-technology position metadata.

- Status: beta
- Group: data-display
- Page: https://www.digitaltableteur.com/design-system/components/virtual-list
- Contract: https://www.digitaltableteur.com/contracts/v1/VirtualList.contract.json

## When to use

Use VirtualList for long, fixed-height collections when rendering every item would be wasteful. Keep item keys stable and row height accurate.

## When not to use

- Do not use it for short collections.
- Do not use it for variable-height rows.
- Do not use it when browser find-in-page must search every item.
- Do not use VirtualList for variable-height rows or full-page text search.

## Look-alikes

The contract names no look-alike with a deciding condition.

## Props

| Prop | Type | Default | Description | Required |
| --- | --- | --- | --- | --- |
| `items` | `Item[]` | none | Complete item collection. | Yes |
| `itemHeight` | `number` | none | Fixed item height in pixels. | Yes |
| `height` | `number` | none | Visible viewport height in pixels. | Yes |
| `getItemKey` | `(item: Item, index: number) => React.Key` | none | Stable item key. | Yes |
| `getItemProps` | `(item: Item, index: number) => VirtualListItemContent` | none | Maps an item to its VirtualListItem chrome (label via `children`, plus optional `icon`, `meta`, `trailingIcon`, `selected`, `tone`). VirtualList injects the position (`posInSet`/`setSize`) and windowing style. | Yes |
| `aria-label` | `string` | none | Accessible list name. | Yes |
| `overscan` | `number` | `3` | Extra rows rendered before and after the viewport. | No |
| `initialScrollOffset` | `number` | `0` | Initial scroll offset in pixels. | No |
| `onRangeChange` | `(range: VirtualListRange) => void` | none | Receives the rendered index range. | No |
| `className` | `string` | none | No description in the contract. | No |

## Variants

No variant dimensions and no props with a fixed set of values.

## Invalid combinations

The contract records no invalid combinations.

## Keyboard

| Key | Behaviour |
| --- | --- |
| PageUp | Named in the contract without a description. |
| PageDown | Named in the contract without a description. |
| Home | Moves to the first item. (standard) |
| End | Moves to the last item. (standard) |

Rows marked (standard) name a key the contract lists without a description; the behaviour shown is the usual one for that key.

## Rules

Every item under When not to use is a MUST NOT. MUST and SHOULD follow RFC 2119.

| Level | Rule | How it is checked |
| --- | --- | --- |
| MUST | ARIA: Viewport uses role=list and an accessible name. | Not yet verified: no evidence record. WCAG 4.1.2. |
| MUST | ARIA: Rendered rows use role=listitem. | Not yet verified: no evidence record. WCAG 4.1.2. |
| MUST | ARIA: Rows expose aria-posinset and aria-setsize. | Not yet verified: no evidence record. WCAG 4.1.2. |
| MUST | Required stories produce no axe violations at the configured severity. | Automated by `npm run test:stories:matrix:ci`. WCAG 2.5.8. |
| MUST | The accessibility tree (role, name, state) matches the committed snapshot for every required story. | Automated by `npm run test:stories:matrix:ci`. WCAG 1.3.1, 4.1.2. |
| MUST | The component remains legible and operable under a real browser forced-colors: active pass. | Automated by `npm run test:stories:hc`. |
| MUST | Every documented keyboard interaction works as specified. | Not yet verified: no evidence record. WCAG 2.1.1, 2.1.2. |
| MUST | A human completed an end-to-end accessibility review of this component. | Manual review, last on 2026-07-26. |
| SHOULD | Measure and provide the exact fixed row height used by rendered items. | Not stated in the contract. |
| SHOULD | Use stable item keys that survive filtering, sorting, and refreshes. | Not stated in the contract. |
| SHOULD | Keep overscan small while preventing blank edges during normal scrolling. | Not stated in the contract. |
| SHOULD | Use range changes for prefetching without coupling them to visual state. | Not stated in the contract. |
| SHOULD NOT | Do not virtualize a short collection that renders cheaply without it. | Not stated in the contract. |

## Install and import

- Install: `npm install @digitaltableteur/react` (version 0.9.1, restricted access on npm).
- Import: `import { VirtualList } from "@digitaltableteur/react";`
- Entry point: `@digitaltableteur/react/content` exports it too.
- Styles: import `@digitaltableteur/react/style.css` once at the app boundary.

## Links

- Machine-readable contract (Design System Contract 1.0): https://www.digitaltableteur.com/contracts/v1/VirtualList.contract.json
- Markdown version of this page: https://www.digitaltableteur.com/design-system/components/virtual-list.md
- Component index as JSON: https://www.digitaltableteur.com/design-system/components.json
- All components: https://www.digitaltableteur.com/design-system/components
- Source: The implementation lives in a private repository. This page, its Markdown twin and the contract are generated from it at build time and are the public source of truth.
