Virtual List
ProNewDraws only the rows in view, so a list of tens of thousands scrolls like a short one.
Installation
pnpm dlx shadcn@latest add @viewport/virtual-list
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
The code behind the preview above comes with Truffle Pro.
Props
| Prop | Type | Default |
|---|---|---|
| items* | T[] | — |
| rowHeight* | numberThe height of every row, in pixels. Rows must be the same height. | — |
| height* | numberThe height of the scrolling viewport, in pixels. | — |
| renderRow* | (item: T, index: number) => React.ReactNode | — |
| getId* | (item: T, index: number) => stringA stable id for each item. | — |
| overscan | numberExtra rows drawn above and below the viewport, so fast scrolling does not show gaps. | 6 |
| label* | stringAccessible name for the list. | — |
| className | string | — |
Accessibility
- Native scrolling in a focusable, named list.
- Each row states its position in the whole list.
- Rows are placed with transforms, so scrolling never triggers layout.