Skip to content
synccn

Virtual List

New

Renders only the rows in view, so 100,000 items scroll like 20. Overscan, scroll-to-row, no dependencies.

100,000
#1page_view20 ms
#2sign_up57 ms
#3checkout94 ms
#4api_call131 ms
#5login168 ms
#6export205 ms
#7page_view242 ms
#8sign_up279 ms
#9checkout316 ms
#10api_call353 ms
#11login390 ms
#12export427 ms
#13page_view464 ms
#14sign_up501 ms

Rendering rows 1–0 only

Installation

$ pnpm dlx shadcn@latest add @synccn/virtual-list

First time in this project? Connect synccn with one command.

Usage

import { VirtualList } from "@/components/ui/virtual-list";<VirtualList items={rows} itemHeight={40} height={400} renderItem={(row) => …} />

API reference

Generated from the component's TypeScript types, so it always matches the code.

VirtualList

Renders only the rows in view, so a list of 100,000 items scrolls as smoothly as 20. No dependencies: fixed row heights, overscan, scroll-to-row and correct list semantics.

  • itemsrequired
    T[]

    Every item. Only the ones in view are rendered.

  • itemHeightrequired
    number

    Height of each row in pixels. Rows must all be this tall.

  • height
    number

    Default 400

    Height of the scrolling area in pixels.

  • overscan
    number

    Default 6

    Extra rows rendered above and below the view, so fast scrolling doesn't flash.

  • renderItemrequired
    (item: T, index: number) => React.ReactNode

    Renders one row.

  • getKey
    (item: T, index: number) => React.Key

    Stable key for a row. Defaults to its index.

  • scrollToIndex
    number

    Scrolls to this row when it changes.

  • onRangeChange
    (range: { start: number; end: number }) => void

    Called with the first and last rendered row as you scroll.

  • empty
    React.ReactNode

    Shown when there are no items.

  • aria-label
    string

    Accessible name for the list.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Helpers

npm packages

Accessibility

  • Rows keep list semantics with aria-setsize and aria-posinset, so screen readers know the real length.

From the source

Read from this component's code when the site builds, so it can't drift.

  • ARIA roles: list, listitem
  • ARIA attributes: aria-label, aria-posinset, aria-setsize
  • Shows a visible focus ring for keyboard users