Skip to content

Vue connection

@sectile/vue/virtual/list accepts an item array, stable keys, and slot markup, then measures real rendered elements automatically.

Install

sh
pnpm add vue @sectile/vue @sectile/virtual

List

vue
<script setup lang="ts">
import { VirtualList } from '@sectile/vue/virtual/list'

const rows = Array.from({ length: 50_000 }, (_, index) => ({
  id: `row-${index}`,
  text: `Row ${index + 1}`,
}))
</script>

<template>
  <VirtualList :items="rows" :get-key="row => row.id" class="list">
    <template #default="{ value: row }">
      <p>{{ row.text }}</p>
    </template>
  </VirtualList>
</template>

<style scoped>
.list { height: 24rem; }
</style>

Omitting size props measures an initial DOM sample before creating the virtual layout. The sample covers the initial render range for a list, the first row for a grid, and the first lane set for masonry. More complex item DOM adds to this bootstrap cost. estimateSize supplies the starting estimate directly, while itemSize skips measurement when every item has the same exact size.

Declarative components

ComponentSurfaceMain input
VirtualListVertical or horizontal listitems, getKey, axis
VirtualGridVertically flowing grid with responsive columnsminLaneSize, maxLaneCount
VirtualMasonryVariable-height cardsminLaneSize, placementPolicy
VirtualSpatialApplication-positioned canvasgetRect, getZIndex

All four components use items, getKey, and the default slot in the same way. Their root element is the scroll container, so set viewport size with CSS height, max-height, flex, or grid layout.

A grid large on both axes

VirtualGrid derives responsive columns within viewport width and flows vertically. For a table or schedule with hundreds of independent rows and columns, connect VirtualizerRoot to trackGridLayoutStrategy. The 300 × 300 grid example contains the complete code.

Low-level building blocks

Use these components with useVirtualizer() for merged cells, reverse axes, or custom measurement rules.

  • VirtualizerRoot: connect state and layout strategy
  • VirtualizerContent: apply full content size
  • VirtualizerItem: connect placement coordinates and measurement

Provide a server-known initialViewport when the first visible range is rendered during SSR.

Released under the MIT License.