Getting startedComponentsDesign tokensThemingTheme synthesizerFrameworksAccessibilityUtilitiesServer renderingBrowser supportContributingChangelogApp ShellAspect GridAuth ShellCenterContainerDashboard GridFloat BarInsetMasonryPage HeaderPage LayoutResizableResponsive SwitcherSectionSettings LayoutSplit PaneStatus BarStickyToolbarAnchor NavBottom NavBreadcrumbBreadcrumb MenuCommand BarDrawerFooterLinkMenubarNavigation MenuPage IndicatorPaginationRailScroll IndicatorScroll SpyScroll To TopSidebarSkip LinkStepper NavTabsTop BarTree ViewAccordionAspect RatioAvatarAvatar GroupCardCarouselCollapsibleColor SwatchCTA BannerDividerEmpty StateFeature CardIconImageImage CompareImage HotspotsInfinite ScrollLightboxMarqueeQR CodeScroll AreaSkeletonSpinnerStackVideoVirtual ListActivity HeatmapAnimated NumberBadgeBar ListChartClockComparisonCountdown TimerData GridDescription ListDiffGaugeJSON TreeKanbanLevel MeterListMeterSparklineStatStepperTagTimelineUptimeValue CardWaveformBlockquoteCode BlockCode GroupGradient TextHighlightKbdKeyboard MapMarkdownNumber FormatProseTerminalTextTime AgoTruncateTypewriterButtonButton GroupCalendarCheckboxChipColor PickerComboboxCopy ButtonDate PickerDate Range PickerField ListFieldsetFile UploadFormHotkeyIcon ButtonImage CropperInline EditInputInput GroupKnobLabelMasked InputMulti SelectNumber InputPassword InputPin InputRadio GroupRange SliderRatingSearchSegmented ControlSelectSignature PadSliderSortable ListSwitch GroupTag InputTextareaTheme ToggleTime PickerToggleTransfer ListTree SelectAlertAnnouncementBannerCommand PaletteConfirmConnection StatusContext MenuConversationDialogDropdown MenuHover CardLoading OverlayNotification PanelPopoverProgressSheetToastTooltip
ARC UIARC Radiant Components
v4.9DocsComponentsTokensSynthesizer
Getting startedFrameworksServer renderingDesign tokensThemingTheme synthesizerTypographyUtilitiesAll componentsAccessibilityBrowser supportChangelogContributingStatsApp ShellAspect GridAuth ShellCenterContainerDashboard GridFloat BarInsetMasonryPage HeaderPage LayoutResizableResponsive SwitcherSectionSettings LayoutSplit PaneStatus BarStickyToolbarAnchor NavBottom NavBreadcrumbBreadcrumb MenuCommand BarDrawerFooterLinkMenubarNavigation MenuPage IndicatorPaginationRailScroll IndicatorScroll SpyScroll To TopSidebarSkip LinkStepper NavTabsTop BarTree ViewAccordionAspect RatioAvatarAvatar GroupCardCarouselCollapsibleColor SwatchCTA BannerDividerEmpty StateFeature CardIconImageImage CompareImage HotspotsInfinite ScrollLightboxMarqueeQR CodeScroll AreaSkeletonSpinnerStackVideoVirtual ListActivity HeatmapAnimated NumberBadgeBar ListChartClockComparisonCountdown TimerData GridDescription ListDiffGaugeJSON TreeKanbanLevel MeterListMeterSparklineStatStepperTagTimelineUptimeValue CardWaveformBlockquoteCode BlockCode GroupGradient TextHighlightKbdKeyboard MapMarkdownNumber FormatProseTerminalTextTime AgoTruncateTypewriterButtonButton GroupCalendarCheckboxChipColor PickerComboboxCopy ButtonDate PickerDate Range PickerField ListFieldsetFile UploadFormHotkeyIcon ButtonImage CropperInline EditInputInput GroupKnobLabelMasked InputMulti SelectNumber InputPassword InputPin InputRadio GroupRange SliderRatingSearchSegmented ControlSelectSignature PadSliderSortable ListSwitch GroupTag InputTextareaTheme ToggleTime PickerToggleTransfer ListTree SelectAlertAnnouncementBannerCommand PaletteConfirmConnection StatusContext MenuConversationDialogDropdown MenuHover CardLoading OverlayNotification PanelPopoverProgressSheetToastTooltip

Virtual List

A scrolling list of fixed-height rows that renders only the rows on screen.

ComponentsVirtual List
contentinteractive
<arc-virtual-list>

Overview

VirtualList renders only the rows on screen. A spacer stands in for the full list height (`items.length × itemHeight`), so the scrollbar behaves as if every row existed, while the DOM holds one screenful plus an `overscan` buffer. Scroll handling is throttled with `requestAnimationFrame`, and the number of DOM nodes stays the same however long the array is. The tests run it with 10,000 rows. In plain JS, HTML or Lit, give it a `renderItem` callback. It's called only for rows on screen and can return anything Lit can render, such as a template, a DOM node or a string. ```js list.items = data; list.renderItem = (item, index) => `${index + 1}. ${item.name}`; ``` In a framework, use the wrapper's own idiom: a `renderItem` prop in React, Preact and Solid, a `row` scoped slot in Vue, a `row` snippet in Svelte, and a `rowTemplate` in Angular. Each of these wrappers listens for `arc-range-change`, tracks the visible range and renders exactly those rows as your framework's own elements. Working with the element directly, you can also drive it yourself. It renders an `item-N` slot for each index in the visible range and fires `arc-range-change` with `{ start, end }` (`end` exclusive) when the range changes, at most once per animation frame. `visibleRange` returns the same values on demand, and `scrollToIndex(n)` jumps to a row. An index past the end is clamped and scrolls to the last row.

Guidelines

Do

  • Use it for lists of 100 or more items, where rendering every row would make scrolling stutter
  • Set `item-height` to the height each row actually renders at
  • Keep `overscan` between 3 and 10. More rows cut flicker but add DOM nodes
  • Use arc-list-item inside rows to match the styling of List
  • Set `items` as a property. A JSON attribute also works, but it puts the whole array in your markup

Don't

  • Don't use it for lists under 50 items. It isn't worth the overhead
  • Don't mix row heights. Every row must be `item-height` tall
  • Don't put scrollable containers inside rows
  • Don't leave the host without a fixed height
  • Don't put all the items in the light DOM and let the component hide them. That's the cost this component exists to avoid

Features

  • All rows share one height, `item-height` (40px by default)
  • `overscan` (5 by default) sets how many extra rows render above and below the window, to cover fast scrolling

Preview

Usage

This component needs JavaScript. Use the Web Component or a framework wrapper.

<arc-virtual-list
  id="my-list"
  item-height="48"
  overscan="5"
  style="height: 400px;"
></arc-virtual-list>

<script type="module">
  const vl = document.getElementById('my-list');

  // Both are properties, not attributes: an array and a function
  // cannot survive being stringified into markup.
  vl.items = Array.from({ length: 10000 }, (_, i) => `Row ${i + 1}`);
  vl.renderItem = (item, index) => {
    const div = document.createElement('div');
    div.textContent = `${index + 1}. ${item}`;
    return div;
  };
</script>

API

visibleRange
The range of currently rendered indices. end is exclusive.
renderItemFunctionnull
(item, index) => unknown returning one row's content. Anything Lit can render: a template, a DOM node, a string. When set, rows come from here and the slots are not used.
itemHeightnumber40
Height in pixels of each row. Must match what actually renders, and must be at least 1: it is a divisor, so a zero would put NaN through every window calculation.
overscannumber5
Rows rendered above and below the visible window to cover fast scrolling. Never negative.
itemsArray[]
The full data array. Only the visible slice is rendered at any given time.

Methods

scrollToIndex(index)index: number
Scroll a row into view.

Events

arc-range-changedetail:{value: {start: number, end: number}, start: number, end: number}
Fired when the visible range changes. end is exclusive.

See also