Componentdata0.49 KB gzipZero dependencies
VirtualList
Windowed list for fixed-height rows: scrollTop math, visible slice renders, spacer divs; smooth scroll.
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add virtual-listOr install the full npm package:
npm install bigbulluiUsage
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 helperZero 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 />| Prop | Type | Description |
|---|---|---|
| items | T[] | List of items to render. |
| itemHeight | number | Height of each item in pixels. |
| height | number | Total visible height of the list container in pixels. |
| render | (item: T, index: number) => React.ReactNode | Renderer function for each item. |
| className | string | Optional Tailwind or custom CSS classes merged with component styles. |