primitives icon indicating copy to clipboard operation
primitives copied to clipboard

[New Primitive] `VirtualList`

Open andrevenancio opened this issue 4 years ago • 2 comments

Feature request

Overview

Infinite scrolling has become some what of a standard on social media platforms. However the more dom elements you create as you scroll, the less performant your page will be. A commonly used technique is to re-use cells and substitute their content as the user scrolls while also increasing the paddingTop to increase the scrollbar. One can see this technique in practice in libraries like react-scrollable-list or react-window. This will be a great addition to the radix primitives family.

Examples in other libraries

react-scrollable-list react-window

Who does this impact? Who is this for?

This component is probably targeted towards advanced users, yet if simple to implement, it should be benefitial to any user.

Additional context

This feature request was also requested on Discord

And there seems to be some public interest on it too :)

andrevenancio avatar Jun 28 '21 10:06 andrevenancio

Thanks for this. As promised, we'll take a look asap. We're working on Select, Toast, and modality work right now, so it won't be possible for at least a couple months. But we'll consider it for the next cycle.

colmtuite avatar Jun 29 '21 14:06 colmtuite

I just want to mention that react-virtuoso is not too hard to set up with ScrollArea.

https://codesandbox.io/p/sandbox/wispy-field-g8w2t3?file=%2FApp.jsx



const TAGS = Array.from({ length: 500 }).map(
  (_, i, a) => `v1.2.0-beta.${a.length - i}`
);

const ScrollAreaDemo = () => {
  const [scrollParent, setScrollParent] = useState();

  return (
    <ScrollArea.Root className="ScrollAreaRoot">
      <ScrollArea.Viewport className="ScrollAreaViewport" ref={setScrollParent}>
        <Virtuoso
          data={TAGS}
          itemContent={(index, tag) => <div className="Tag">{tag}</div>}
          customScrollParent={scrollParent ?? undefined}
        />
      </ScrollArea.Viewport>
      <ScrollArea.Scrollbar
        className="ScrollAreaScrollbar"
        orientation="vertical"
      >
        <ScrollArea.Thumb className="ScrollAreaThumb" />
      </ScrollArea.Scrollbar>
    </ScrollArea.Root>
  );
};

Can be helpful for anyone who's still waiting for VirtualList and couldn't make other virtualization libraries work.

grumd avatar Aug 06 '22 15:08 grumd

Is the sandbox still available? I would like to take a look but the link isn't working

marcoripa96 avatar Jan 27 '23 21:01 marcoripa96

@marcoripa96 Sorry, accidentally deleted the old sandbox. I just added a new one and posted the code in the comment as well.

grumd avatar Feb 10 '23 09:02 grumd

Hi, I'm author of https://github.com/inokawa/virtua .

It's lightweight (about 3x lighter than react-virtuoso) and made with easy virtualization in mind. I hope it may help someone wants headless virtualization.

https://inokawa.github.io/virtua/?path=/story/advanced-with-radix-ui--default https://github.com/inokawa/virtua/blob/main/stories/advanced/With%20radix-ui.stories.tsx

inokawa avatar Sep 08 '23 13:09 inokawa

Hi, I'm author of https://github.com/inokawa/virtua .

It's lightweight (about 3x lighter than react-virtuoso) and made with easy virtualization in mind. I hope it may help someone wants headless virtualization.

https://inokawa.github.io/virtua/?path=/story/advanced-with-radix-ui--default https://github.com/inokawa/virtua/blob/main/stories/advanced/With%20radix-ui.stories.tsx

You saved me life 🫶

anteqkois avatar Jan 04 '24 19:01 anteqkois

great lib @inokawa! appreciate the effort you made

davidsonsns avatar Feb 23 '24 06:02 davidsonsns