menu_bookDocumentation

VirtualGrid: Virtualized Grid Panel for Large Item Collections

calendar_today May 20, 2026 schedule ~1 min read person PatrickJr verified 50
VirtualGrid is a s&box UI Panel that virtualizes large item collections — only rendering visible cells. If you have thousands of items, it creates only the few on screen and recycles them as you scroll.

Razor Usage

CSHARP
<VirtualGrid Items=@Items ItemSize=@(120)>
    <Item Context="item">
        @if (item is Package entry)
        {
            <SpawnButton Icon="@entry.Thumb" Action="@(() => Spawn(entry))"></SpawnButton>
        }
    </Item>
</VirtualGrid>

@code
{
    public Package[] Items { get; set; }
}

Properties

Styling Requirements

The VirtualGrid element must have an explicit size (typically width: 100%; height: 100%). Use gap styles on the VirtualGrid element for spacing between cells.

Gotchas

  • All items must be the same size (defined by ItemSize)
  • The grid won't render without explicit width/height in styles
  • Items are created/destroyed as you scroll — don't store state in cell panels that needs to persist across scrolling
Was this helpful?