Add support for custom scroller in VirtuosoMasonry

Author: Weiting-ZhangCreated Nov 13, 2025Updated Apr 1, 2026

Hi @petyosi and React Virtuoso maintainers,

First off — thanks for building and maintaining React Virtuoso. It’s a fantastic library and the VirtuosoMasonry component is very useful for image-gallery / Pinterest-style layouts.

Problem / Use-case

I’m building a responsive masonry gallery where:

  • I have an outer container which is the scrollable area (not window)

  • I want to include a header/title inside that same scrollable area (so the header scrolls together with the gallery items)

  • I need the scroller to be a custom div (so I can hook into scrollTop, scrollableRef, track events, etc)

  • I still want to use VirtuosoMasonry for its virtualization + responsive columns

At present I found that VirtuosoMasonry does not allow passing a custom scroller component or ref (unlike Virtuoso which supports a components.Scroller or customScrollParent). The API only allows standard DOM attributes (className, style, etc) applied to the internal scroll element, but not full replacement of it.

This limitation means I cannot hook into the outer container scroll context, and VirtuosoMasonry ends up only rendering the first screen (because the internal scroll container is not the one being scrolled).

✅ Feature Request

Would it be possible to add support for something like:

typescript
<VirtuosoMasonry
  data={…}
  columnCount={…}
  // new prop
  scrollElementRef={myScrollableRef}
  // or
  components={{
    Scroller: MyCustomScroller
  }}
 // or
 scrollTop={{scrollTop}}
/>

Benefits

Developers can embed VirtuosoMasonry inside complex UIs where the scroll context is not window — e.g., dashboards, modals, nested containers.

Enables tracking of scroll position, custom analytics, or sticky elements inside the scroll area.

Keeps the performance benefits of VirtuosoMasonry while increasing flexibility.

Additional Info

Library version: @virtuoso.dev/masonry": "^1.3.5"