Skip to main content
You are viewing Pre-Alpha documentation.
Vuetify0 Logo
Theme
Mode
Palettes
Accessibility
Vuetify One
Sign in to Vuetify One

Access premium tools across the Vuetify ecosystem — Bin, Play, Studio, and more.

Not a subscriber? See what's included

createVirtual

Virtual scrolling composable for efficiently rendering large lists by only rendering visible items.


IntermediateApr 5, 2026

Usage

The createVirtual composable efficiently renders large lists by only mounting visible items plus a small overscan buffer. Pass an array of items and configure the item height to get back sliced items, scroll handlers, and positioning values.

vue
<script setup lang="ts">
  import { createVirtual } from '@vuetify/v0'
  import { shallowRef } from 'vue'

  const items = shallowRef(
    Array.from({ length: 10_000 }, (_, i) => `Item ${i + 1}`)
  )

  const { element, items: visible, offset, size, scroll, scrollTo } = createVirtual(items, {
    itemHeight: 40,
  })
</script>

<template>
  <div ref="element" class="h-[300px] overflow-y-auto" @scroll="scroll">
    <div :style="{ height: `${offset}px` }" />
    <div v-for="item in visible" :key="item.index">
      {{ item.raw }}
    </div>
    <div :style="{ height: `${size}px` }" />
  </div>
</template>

Architecture

The rendering pipeline transforms scroll events into visible item ranges:

Virtual Rendering Pipeline

Use controls to zoom and pan. Click outside or press Escape to close.

Virtual Rendering Pipeline

Reactivity

Property/MethodReactiveNotes
elementRef, assign scroll container
itemsComputed, visible items with index
offsetShallowRef, readonly (top spacer height)
sizeShallowRef, readonly (bottom spacer height)
stateShallowRef ('loading' | 'empty' | 'error' | 'ok')
Tip

Source items The items ref passed to createVirtual() is watched for changes. When items change, the virtual scroller updates automatically.

Examples

10,000-Item Virtual List

A scrollable list of 10,000 items that only renders visible rows, with jump-to-index and add-items controls.

0 (rendered) / 10000

API Reference

The following API details are for the createVirtual composable.

Functions

createVirtual

(items: Ref<readonly T[], readonly T[]>, _options?: VirtualOptions) => VirtualContext<T>

Virtual scrolling composable for efficiently rendering large lists

createVirtualContext

(items: Ref<readonly T[], readonly T[]>, _options?: VirtualContextOptions) => ContextTrinity<VirtualContext<T>>

Creates a virtual scrolling context with dependency injection support.

useVirtual

(namespace?: string) => VirtualContext<T>

Returns the current virtual context from dependency injection.

Options

itemHeight

string | number | null | undefined

The height of the item.

height

string | number | undefined

The height of the container.

overscan

number | undefined

The number of extra items to render.

direction

VirtualDirection | undefined

The direction of the scrolling.

anchor

VirtualAnchor | undefined

The anchor of the scrolling.

anchorSmooth

boolean | undefined

Whether to smooth the anchor position.

onStartReached

((distance: number) => void | Promise<void>) | undefined

The callback to call when the start is reached.

onEndReached

((distance: number) => void | Promise<void>) | undefined

The callback to call when the end is reached.

startThreshold

number | undefined

The threshold for the start.

endThreshold

number | undefined

The threshold for the end.

momentum

boolean | undefined

Whether to enable momentum scrolling.

elastic

boolean | undefined

Whether to enable elastic scrolling.

Properties

element

Ref<HTMLElement | undefined, HTMLElement | undefined>

The element that is being virtualized.

items

ComputedRef<VirtualItem<T>[]>

The items that are being virtualized.

offset

Readonly<ShallowRef<number>>

The offset of the virtualized items.

size

Readonly<ShallowRef<number>>

The size of the virtualized items.

state

ShallowRef<VirtualState>

The state of the virtualized items.

Methods

scrollTo

(index: number, options?: ScrollToOptions) => void

Scroll to an item by index.

scroll

() => void

The scroll event handler.

scrollend

() => void

The scrollend event handler.

resize

(index: number, height: number) => void

Resize an item by index.

reset

() => void

Reset the virtualized items.

Benchmarks

Every operation is profiled across multiple dataset sizes to measure real-world throughput. Each benchmark is assigned a performance tier—good, fast, blazing, or slow—and groups are scored by averaging their individual results so you can spot bottlenecks at a glance. This transparency helps you make informed decisions about which patterns scale for your use case. Learn more in the benchmarks guide.

View benchmark source↗

Was this page helpful?

© 2016-1970 Vuetify, LLC
Ctrl+/