npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

clear-virtual-list

v0.0.4

Published

A lightweight, performant component for list virtualization in React

Readme

npm version

React Virtualized Resizable List

A React virtualization utility for rendering large lists with dynamic, resizable item heights, built around automatic DOM measurement and an internal layout cache.

Unlike traditional virtualized list libraries that rely on explicit item measurement APIs or fixed-size assumptions, this implementation works directly with ReactNode[] and continuously refines layout based on real DOM feedback.

⚙️ API

<Virtualized />

A container component that virtualizes a list of ReactNode elements with dynamic height support.

| Prop | Type | Description | | ----------- | ------------------------- |--------------------------------------------------------------------------------------------| | children | ReactNode[] | List of items to be virtualized | | height | CSSProperties['height'] | Height of the scroll container | | width | CSSProperties['width'] | Optional width of the scroll container | | className | string | Optional class name for container | | style | CSSProperties | Additional inline styles | | overScan | number | Number of extra items rendered above and below the visible viewport for smoother scrolling |

📏 Default behavior

If overScan is not provided, a default internal value is used. Items are measured automatically via ResizeObserver. Layout is recalculated incrementally as items mount or change size.

🧠 Notes

children are treated as a static array structure (ReactNode[]), not a render-prop stream. Virtualization is driven by scroll position + internal offset cache. Item sizes are not required upfront — they are inferred at runtime.

🚀 Key Features

⚡ Zero-config virtualization

No item render functions, no size estimators, no manual measurement hooks required.

Just pass:

import Virtualized from 'clear-virtual-list';

<Virtualized height={500}>
  {items.map(item => <div className={row} onClick={clickHandler}>{item}</div>)}
</Virtualized>

📏 Dynamic height support

List items can change height at any time (expansion, collapse, async content loading, etc.).

The system automatically:

  • measures elements via ResizeObserver
  • updates internal offsets incrementally
  • repositions affected rows without full recomputation

🧠 Self-adjusting layout model

Instead of assuming fixed item size, the library maintains:

  • a per-row offset cache
  • an evolving average row height estimate
  • incremental correction when real DOM measurements arrive

This allows the list to remain stable even when item heights are initially unknown or heterogeneous.

🔄 Incremental layout correction

When item size changes:

  • only affected offsets are updated
  • downstream rows are adjusted incrementally
  • no full list reflow is required

This keeps scroll behavior smooth even under frequent resize events.

📦 ReactNode-first API

The library works directly with React elements:

  • no render-prop abstraction
  • no item renderer indirection layer
  • no external data normalization required

🧪 Performance characteristics

Designed to handle:

  • 100,000–400,000 items
  • rapid scroll wheel / trackpad flicking
  • scrollbar drag scrolling
  • dynamic DOM height changes

Rendering is strictly bounded to the visible viewport plus overscan region.

🧩 Internal model (high level)

The virtualization logic is based on three core structures:

Offset cache — stores cumulative positions of measured rows Height registry — stores observed DOM heights per index Estimated row height — used for unmeasured items

As elements mount and resize, estimates are progressively replaced with real measurements, improving layout accuracy over time.

📌 Design philosophy

This library prioritizes:

  • simplicity of integration
  • correctness under dynamic UI changes
  • minimal API surface
  • DOM-driven layout truth (not pre-declared sizes)

The goal is to make virtualization behave like a natural extension of React rendering, rather than a separate abstraction layer.

⚠️ Trade-offs

This approach intentionally:

  • keeps ReactNode creation outside the virtualizer (for API simplicity)
  • relies on runtime measurement instead of precomputed layout
  • uses heuristic-based estimation for initial render pass

These trade-offs favor developer experience and adaptability over strict theoretical optimality.

❓ Why not use existing solutions?

There are several well-established virtualization libraries in the React ecosystem, such as React Window and TanStack Virtual. They are powerful, battle-tested, and suitable for most production use cases.

This library does not aim to replace them. It takes a different approach in a few specific areas.

🧩 1. Simpler mental model

Most virtualization libraries require the developer to think in terms of:

item count item renderer function explicit measurement or estimation logic layout configuration (fixed/variable size modes)

This library removes that abstraction layer.

You work directly with:

  • ReactNode[] → virtualized rendering

  • No render-prop layer, no explicit size model setup.

  • The goal is to reduce the conceptual distance between “React rendering” and “virtualized rendering”.

📏 2. No explicit size management API

Traditional libraries usually require one of:

  • fixed item height
  • estimateSize function
  • manual measurement hooks

This library instead:

  • measures DOM nodes automatically via ResizeObserver
  • builds layout incrementally from real rendered output
  • adapts when item size changes at runtime

This makes it more suitable for cases where:

  • item height is not known in advance
  • height can change after mount (expansion, async content, dynamic UI)

🔄 3. Designed for mutable layouts

This implementation assumes that:

item height is not a stable property

Many virtualization systems treat height as either:

static (fixed-size mode), or externally provided (estimated mode)

Here, height is treated as:

a runtime-evolving property of the DOM itself

The layout model continuously self-corrects as measurements arrive.

⚙️ 4. Reduced configuration surface

Existing solutions are highly configurable, which is powerful but increases complexity:

  • measurement strategies
  • cache strategies
  • scroll container handling
  • item key management

This library intentionally reduces configuration to:

“wrap your list and render it”

At the cost of flexibility, but with significantly lower setup overhead.

⚠️ When NOT to use this library

This approach is not optimal if you need:

  • highly customized rendering pipelines (render-props / data-driven virtualization)
  • complex grid layouts or multi-axis virtualization
  • strict deterministic layout behavior across environments
  • fine-grained control over measurement lifecycle
  • integration with existing virtualization infrastructure

In those cases, React Window or TanStack Virtual are better choices.

💬 Closing note

This library is not trying to reinvent virtualization theory — it’s an attempt to make dynamic-height virtualization feel unforced in React, without requiring the developer to design a rendering pipeline around it.

📄 License

MIT

👤 Author

Andrew Bubnov