Componentdata0.49 KB gzipZero dependencies

VirtualList

Windowed list for fixed-height rows: scrollTop math, visible slice renders, spacer divs; smooth scroll.

Preview

Live Preview
Open ↗

Installation

Tokens guide →

Add to your project via CLI (zero dependencies, code you own):

npx bigbullui add virtual-list

Or install the full npm package:

npm install bigbullui

Usage

tsx7 lines
import { VirtualList } from "@/components/ui/virtual-list" <VirtualList  items={Array.from({ length: 100 }, (_, i) => i)}  itemHeight={40}  height={400}  render={(item) => <div key={item} className="p-2 bg-muted text-sm">Item {item}</div>} />

Source code

virtual-list.tsx + 1 helper

Zero third-party dependencies (2 local files shown in tabs below).

tsxvirtual-list.tsx60 lines
"use client"; import * as React from "react";import { cn } from "./lib/utils"; export type VirtualListProps<T> = {  items: T[];  itemHeight?: number;  height?: number;  render?: (item: T, index: number) => React.ReactNode;  className?: string;} & React.HTMLAttributes<HTMLElement>; export function VirtualList<T>({  items = [],  itemHeight = 40,  height = 320,  render,

Props

Interactive Prop Playground

Tweak parsed AST props below to generate ready-to-paste JSX.

tsx3 lines
import { VirtualList } from "@/components/ui/virtual-list"; <VirtualList />
PropTypeDescription
itemsT[]List of items to render.
itemHeightnumberHeight of each item in pixels.
heightnumberTotal visible height of the list container in pixels.
render(item: T, index: number) => React.ReactNodeRenderer function for each item.
classNamestringOptional Tailwind or custom CSS classes merged with component styles.