Virtua
A zero-config, fast and small (~3kB) virtual list (and grid) component for React, Vue, Solid, Svelte and Angular.
Install / Use
npx skills add inokawa/virtuaInstalls into whichever agent you are using.
README
virtua
A zero-config, fast and small (~3kB) virtual list (and grid) component for React, Vue, Solid, Svelte and Angular.

If you want to check the difference with the alternatives right away, see comparison section.
Motivation
This project is a challenge to rethink virtualization. The goals are...
- Zero-config virtualization: This library is designed to give the best performance without configuration. It also handles common hard things in the real world (dynamic size measurement, scroll position adjustment while reverse scrolling and imperative scrolling, iOS support, etc).
- Fast: Natural virtual scrolling needs optimization in many aspects (eliminate frame drops by reducing CPU usage and GC, reduce synchronous layout recalculation, reduce visual jumps on repaint, optimize with CSS, optimize for JIT, optimize for frameworks, etc). We are trying to combine the best of them.
- Small: Its bundle size should be small as much as possible to be friendly with modern web development. Currently each components are ~3kB gzipped and tree-shakeable.
- Flexible: Aiming to support many usecases - fixed size, dynamic size, horizontal scrolling, reverse scrolling, RTL, mobile, infinite scrolling, scroll restoration, DnD, keyboard navigation, sticky, placeholder and more. See live demo.
- Framework agnostic: React, Vue, Solid, Svelte and Angular are supported. We could support other frameworks in the future.
Demo
https://inokawa.github.io/virtua/
Install
npm install virtua
If you use this lib in legacy browsers which does not have ResizeObserver, you should use polyfill.
Getting started
React
react >= 16.14 is required.
If you use ESM and webpack 5, use react >= 18 to avoid Can't resolve react/jsx-runtime error.
Vertical scroll
import { VList } from "virtua";
// children
export const App = () => {
return (
<VList style={{ height: 800 }}>
{Array.from({ length: 1000 }).map((_, i) => (
<div
key={i}
style={{
height: Math.floor(Math.random() * 10) * 10 + 10,
borderBottom: "solid 1px gray",
background: "white",
}}
>
{i}
</div>
))}
</VList>
);
};
// or render prop
export const App = () => {
const items = Array.from({ length: 1000 }).map(
() => Math.floor(Math.random() * 10) * 10 + 10,
);
return (
<VList data={items} style={{ height: 800 }}>
{(d, i) => (
<div
key={i}
style={{
height: d,
borderBottom: "solid 1px gray",
background: "white",
}}
>
{i}
</div>
)}
</VList>
);
};
Horizontal scroll
import { VList } from "virtua";
export const App = () => {
return (
<VList style={{ height: 400 }} horizontal>
{Array.from({ length: 1000 }).map((_, i) => (
<div
key={i}
style={{
width: Math.floor(Math.random() * 10) * 10 + 10,
borderRight: "solid 1px gray",
background: "white",
}}
>
{i}
</div>
))}
</VList>
);
};
Customization
VList is a recommended solution which works like a drop-in replacement of simple list built with scrollable div (or removed virtual-scroller element). For more complicated styling or markup, use Virtualizer.
import { Virtualizer } from "virtua";
export const App = () => {
return (
<div style={{ overflowY: "auto", overflowAnchor: "none", height: 800 }}>
<div style={{ height: 40 }}>header</div>
<Virtualizer startMargin={40}>
{Array.from({ length: 1000 }).map((_, i) => (
<div
key={i}
style={{
height: Math.floor(Math.random() * 10) * 10 + 10,
borderBottom: "solid 1px gray",
background: "white",
}}
>
{i}
</div>
))}
</Virtualizer>
</div>
);
};
Window scroll
import { WindowVirtualizer } from "virtua";
export const App = () => {
return (
<div style={{ padding: 200 }}>
<WindowVirtualizer>
{Array.from({ length: 1000 }).map((_, i) => (
<div
key={i}
style={{
height: Math.floor(Math.random() * 10) * 10 + 10,
borderBottom: "solid 1px gray",
background: "white",
}}
>
{i}
</div>
))}
</WindowVirtualizer>
</div>
);
};
Vertical and horizontal scroll
import { experimental_VGrid as VGrid } from "virtua";
export const App = () => {
return (
<VGrid style={{ height: 800 }} row={1000} col={500}>
{({ rowIndex, colIndex }) => (
<div
style={{
width: ((colIndex % 3) + 1) * 100,
background: "white",
borderLeft: colIndex !== 0 ? "solid 1px gray" : undefined,
borderTop: rowIndex !== 0 ? "solid 1px gray" : undefined,
}}
>
{rowIndex} / {colIndex}
</div>
)}
</VGrid>
);
};
Vue
vue >= 3.2 is required.
<script setup>
import { VList } from "virtua/vue";
const sizes = [20, 40, 180, 77];
const data = Array.from({ length: 1000 }).map((_, i) => sizes[i % 4]);
</script>
<template>
<VList :data="data" :style="{ height: '800px' }" #default="{ item, index }">
<div
:key="index"
:style="{
height: item + 'px',
background: 'white',
borderBottom: 'solid 1px #ccc',
}"
>
{{ index }}
</div>
</VList>
</template>
Solid
solid-js >= 1.0 is required.
import { VList } from "virtua/solid";
export const App = () => {
const sizes = [20, 40, 180, 77];
const data = Array.from({ length: 1000 }).map((_, i) => sizes[i % 4]);
return (
<VList data={data} style={{ height: "800px" }}>
{(d, i) => (
<div
style={{
height: d + "px",
"border-bottom": "solid 1px #ccc",
background: "#fff",
}}
>
{i()}
</div>
)}
</VList>
);
};
Svelte
svelte >= 5.0 is required.
<script lang="ts">
import { VList } from "virtua/svelte";
const sizes = [20, 40, 180, 77];
const data = Array.from({ length: 1000 }).map((_, i) => sizes[i % 4]);
</script>
<VList {data} style="height: 100vh;" getKey={(_, i) => i}>
{#snippet children(item, index)}
<div
style="
height: {item}px;
background: white;
border-bottom: solid 1px #ccc;
"
>
{index}
</div>
{/snippet}
</VList>
Angular
@angular/core >= 20 is required. The components are zoneless-ready and work with both zone.js and provideZonelessChangeDetection.
import { Component } from "@angular/core";
import { VList } from "virtua/angular";
const sizes = [20, 40, 180, 77];
@Component({
selector: "app-root",
imports: [VList],
template: `
<virtua-vlist [data]="data" [getKey]="getKey" style="height: 800px;">
<ng-template let-item let-index="index">
<div
[style.height.px]="item"
style="background: white; border-bottom: solid 1px #ccc;"
>
{{ index }}
</div>
</ng-template>
</virtua-vlist>
`,
})
export class App {
protected readonly data = Array.from({ length: 1000 }).map(
(_, i) => sizes[i % 4]!,
);
protected readonly getKey = (_: number, i: number) => i;
}
Other bindings
- vanilla-virtua: virtua for vanilla js
Documentation
- API reference
- Storybook examples for more usages
- DeepWiki
FAQs
Is there any way to improve performance further?
In complex usage, especially if you re-render frequently the parent of virtual scroller or the children are tons of items, children element creation can be a performance bottle neck. That's because creating React elements is fast enough but not free and new React element instances break some of memoization inside virtual scroller.
One solution is memoization with useMemo. You can use it to reduce computation and keep the elements' instance the same. And if you want to pass state from parent to the items, using context instead of props may be better because i
Related Skills
node-connect
385.6kDiagnose OpenClaw Android, iOS, or macOS node pairing, QR/setup code, route, auth, and connection failures.
imsg
385.6kUse the imsg CLI from OpenClaw agents for iMessage/SMS DMs, groups, replies, reactions, polls, watching, and private-API actions.
Agent Development
140.7kThis skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or…
review-duplication
106.4kUse this skill during code reviews to proactively investigate the codebase for duplicated functionality, reinvented wheels, or failure to reuse existing project best practices and shared utilities.
