VirtualizedList
Description
VirtualizedList is a collection component designed to efficiently render large sets of items by virtualizing the DOM content. Instead of rendering all items at once, it breaks the dataset into pages and only renders the pages within a defined “materialized window.” As the user scrolls, pages that move out of view are removed while new pages are dynamically added. This approach significantly reduces the number of DOM elements and improves performance, especially when list items involve complex or resource-intensive operations.
Usage
Instantiate the VirtualizedList using the provided static helper method from Tesserae.UI. You can set the list items and optionally provide a custom empty list message. The following example demonstrates how to create a VirtualizedList with a large set of items:
Public Properties
The VirtualizedList does not expose additional public properties. Its configuration is done through the method parameters during instantiation.
API reference
public class VirtualizedList : IComponentA VirtualizedList component that renders only the visible portion of a large list to improve performance.
Constructors
Methods
public VirtualizedList WithEmptyMessage(Func<IComponent> emptyListMessageGenerator)Sets a message to display when the list is empty.
Parameters
- emptyListMessageGenerator
- A function that returns the empty list message component.
Returns
The current instance of the type.
public VirtualizedList WithListItems(IEnumerable<IComponent> listItems)Adds items to the virtualized list.
Parameters
- listItems
- The items to add.
Returns
The current instance of the type.
Samples
Virtualized List with 5,000 Items
This sample creates 5,000 rows. Only the rows currently in view (plus a small buffer) are actually present in the DOM — scroll rapidly to see the recycler in action. Each row is styled with a fixed height so the scroll position is computed accurately.
Virtualized List with Custom Empty Message
When the items collection is empty, WithEmptyMessage is used instead. The placeholder can include icons, captions, and call-to-action buttons.