AdaptTable for shadcn-vue

Row and column virtualization in shadcn-vue

Compose virtualize() and the table renders the rows in view plus a small overscan, whatever the dataset's size — forty thousand rows on this page, a few dozen of them in the page at once.

The scroll box scrolls rather than the page, and sorting and filtering keep working on the whole dataset rather than on what is drawn. virtualize({ virtualizeColumns: true }) does the same across, for column sets wider than the box.

The code

<script setup lang="ts">
import type { ColumnDef } from "@adapttable/vue";
import { DataTable } from "@adapttable/shadcn-vue";
import { virtualize } from "@adapttable/shadcn-vue/virtualize";

defineProps<{ rows: readonly Person[] }>();

const columns: ColumnDef<Person>[] = [
  { key: "name", sortable: true },
  { key: "team" },
  { key: "budget", sortable: true },
];
const rowKey = (row: Person) => row.id;
const features = [virtualize({ maxHeight: 480 })];
</script>

<template>
  <DataTable
    :data="rows"
    :columns="columns"
    :row-key="rowKey"
    pagination-mode="infinite"
    :features="features"
  />
</template>

Install

pnpm add @adapttable/shadcn-vue @adapttable/vue @adapttable/core reka-ui

The same feature in the other kits

More shadcn-vue features

Reference: virtualization. More of this kit: AdaptTable for shadcn-vue, or the live demo.