AdaptTable for shadcn-vue

CSV export in shadcn-vue

Compose exportCsv() and an export button joins the toolbar. It writes the page on screen as it stands — sorted, filtered and searched — to a CSV file the browser downloads.

A column's exportValue decides what the file gets, so a cell that shows a formatted date range exports the plain start date a spreadsheet sorts.

The code

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

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 = [exportCsv()];
</script>

<template>
  <DataTable
    :data="rows"
    :columns="columns"
    :row-key="rowKey"
    :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: exporting, export-pdf. More of this kit: AdaptTable for shadcn-vue, or the live demo.