VirtualList

A long list where only the rows near the viewport are in the DOM.

Import it from rei-kit: import { VirtualList } from 'rei-kit'

Open VirtualList in the live documentation, where every prop below is a control you can change, in four materials and ten palettes.

Usage

<script setup lang="ts">
import { VirtualList } from 'rei-kit'

/** Long enough that rendering all of it would be the reason to reach for this. */
const ROWS = Array.from({ length: 5000 }, (_, index) => ({
  id: index,
  name: `Row ${index + 1}`,
}))
</script>

<template>
  <VirtualList
    :items="ROWS"
    :row-height="36"
    label="Five thousand rows"
    class="border-hair max-h-56 rounded-xl border"
  >
    <template #default="{ item }">
      <span class="text-ink flex h-full items-center px-3 text-sm">{{ item.name }}</span>
    </template>
  </VirtualList>
</template>

Props

Props
PropTypeRequired or defaultWhat it is for
itemsreadonly T[]yesThe whole list. Only the rows near the viewport are rendered.
rowHeightnumberyesEvery row is this tall, in pixels.
labelstringyesNames the list, e.g. "Bütün kayıtlar". Already translated.
virtualizeAfternumber50Below this many rows the list is not windowed at all.
scrollbar'auto' | 'hidden''auto'Passed to the scroll area: `hidden` takes the native bar away.

About rei-kit

rei-kit is an accessible Vue 3 and Tailwind CSS 4 component library: 106 components, themed by role rather than by colour on three independent axes — ten WCAG-checked palettes, four materials and light or dark, each switched with one attribute. Typed, tested, SSR-safe, no runtime dependencies, MIT.

pnpm add rei-kit · npm · GitHub