Skip to content

DataTable ​

DataTable is a headless, generic table built on @tanstack/vue-table v9, styled with the same primitives as Table. You describe your rows with column definitions, and it renders sortable headers, an optional expansion row, a loading state, and an empty state.

vue
<script setup lang="ts">
import { createColumnHelper } from '@tanstack/vue-table'
import { DataTable, type DataTableFeatures } from '@myghf/ui'

const data = [
  { id: 'r1', patient: 'Amina Farouk', waiting: 3 },
]
const columnHelper = createColumnHelper<DataTableFeatures, (typeof data)[number]>()
const columns = columnHelper.columns([
  columnHelper.accessor('patient', { header: 'Patient' }),
  columnHelper.accessor('waiting', { header: 'Waiting (days)' }),
])
const getRowId = (row: (typeof data)[number]) => row.id
</script>

<template>
  <DataTable :data="data" :columns="columns" :get-row-id="getRowId" />
</template>

Examples ​

Sorting ​

Click a header to sort by that column; click again to reverse. By default the sort lives in the component and is reported through update:sorting. Bind v-model:sorting to own the state in the parent instead — the component then only sorts when you write the prop back, which is what a server-side sort (manual) needs. Set sortable to false to make every header static.

Amina FaroukCardiology3
Youssef KamalRadiology12
Layla HassanOncology1
Omar SaidCardiology7

Sorted by: the original order

vue
<script setup lang="ts">
import { ref } from 'vue'
import { createColumnHelper } from '@tanstack/vue-table'
import { DataTable, type DataTableFeatures } from '@myghf/ui'

interface Referral {
  id: string
  patient: string
  clinic: string
  waiting: number
}

const referrals: Referral[] = [
  { id: 'r1', patient: 'Amina Farouk', clinic: 'Cardiology', waiting: 3 },
  { id: 'r2', patient: 'Youssef Kamal', clinic: 'Radiology', waiting: 12 },
  { id: 'r3', patient: 'Layla Hassan', clinic: 'Oncology', waiting: 1 },
  { id: 'r4', patient: 'Omar Said', clinic: 'Cardiology', waiting: 7 },
]

const columnHelper = createColumnHelper<DataTableFeatures, Referral>()
const columns = columnHelper.columns([
  columnHelper.accessor('patient', { header: 'Patient' }),
  columnHelper.accessor('clinic', { header: 'Clinic' }),
  columnHelper.accessor('waiting', { header: 'Waiting (days)' }),
])

const getRowId = (row: Referral) => row.id
const sorting = ref<{ id: string; desc: boolean }[]>([])
</script>

<template>
  <div class="space-y-3">
    <DataTable
      :data="referrals"
      :columns="columns"
      :get-row-id="getRowId"
      :sortable="true"
      @update:sorting="sorting = $event"
    />

    <p class="text-sm text-muted">
      Sorted by:
      {{
        sorting.length
          ? sorting.map((s) => `${s.id} ${s.desc ? 'descending' : 'ascending'}`).join(', ')
          : 'the original order'
      }}
    </p>
  </div>
</template>

Expanding rows and cell slots ​

With expandable, clicking a row toggles an expansion row rendered through the expansion slot. Expansion is single-row (opening one closes the other). Use a cell-<columnId> slot to override a column's cell — here the status column renders a Tag.

Toggle row
Amina FaroukReady
Youssef KamalPending
Layla HassanReady
vue
<script setup lang="ts">
import { ref } from 'vue'
import { createColumnHelper } from '@tanstack/vue-table'
import { DataTable, Tag, type DataTableFeatures } from '@myghf/ui'

interface Order {
  id: string
  patient: string
  status: 'Ready' | 'Pending'
  notes: string
}

const orders: Order[] = [
  { id: 'o1', patient: 'Amina Farouk', status: 'Ready', notes: 'Consent signed; slot booked for Thursday.' },
  { id: 'o2', patient: 'Youssef Kamal', status: 'Pending', notes: 'Awaiting the radiology report.' },
  { id: 'o3', patient: 'Layla Hassan', status: 'Ready', notes: 'Pre-op bloods completed.' },
]

const columnHelper = createColumnHelper<DataTableFeatures, Order>()
const columns = columnHelper.columns([
  columnHelper.accessor('patient', { header: 'Patient' }),
  columnHelper.accessor('status', { header: 'Status' }),
])

const getRowId = (row: Order) => row.id
const expanded = ref<Record<string, boolean>>({})
</script>

<template>
  <DataTable
    v-model:expanded="expanded"
    :data="orders"
    :columns="columns"
    :get-row-id="getRowId"
    expandable
    empty-label="No orders"
  >
    <template #cell-status="{ value }">
      <Tag :tone="value === 'Ready' ? 'success' : 'warning'">{{ value }}</Tag>
    </template>
    <template #expansion="{ row }">
      <p class="text-sm text-muted">{{ row.original.notes }}</p>
    </template>
  </DataTable>
</template>

Loading ​

Set loading while data is in flight and DataTable replaces the body with loadingRows placeholder rows (default 5), each a Skeleton per column, while keeping the real header. The wrapper gets aria-busy="true" and a screen-reader-only loadingLabel (default Loading…) announces the status. The empty state is suppressed while loading, so an empty data array does not flash "No results" before the rows arrive.

Loading referrals
vue
<script setup lang="ts">
import { ref } from 'vue'
import { createColumnHelper } from '@tanstack/vue-table'
import { Button, DataTable, type DataTableFeatures } from '@myghf/ui'

interface Referral {
  id: string
  patient: string
  clinic: string
  waiting: number
}

const referrals: Referral[] = [
  { id: 'r1', patient: 'Amina Farouk', clinic: 'Cardiology', waiting: 3 },
  { id: 'r2', patient: 'Youssef Kamal', clinic: 'Radiology', waiting: 12 },
  { id: 'r3', patient: 'Layla Hassan', clinic: 'Oncology', waiting: 1 },
]

const columnHelper = createColumnHelper<DataTableFeatures, Referral>()
const columns = columnHelper.columns([
  columnHelper.accessor('patient', { header: 'Patient' }),
  columnHelper.accessor('clinic', { header: 'Clinic' }),
  columnHelper.accessor('waiting', { header: 'Waiting (days)' }),
])

const getRowId = (row: Referral) => row.id

const loading = ref(true)
</script>

<template>
  <div class="space-y-3">
    <DataTable
      :data="referrals"
      :columns="columns"
      :get-row-id="getRowId"
      :loading="loading"
      :loading-rows="3"
      loading-label="Loading referrals"
    />

    <Button variant="outline" size="sm" @click="loading = !loading">
      {{ loading ? 'Finish loading' : 'Reload' }}
    </Button>
  </div>
</template>

Types ​

Row selection and bulk actions ​

Set selectable and bind v-model:selection to a map keyed by row id (provide getRowId so the keys are stable). A leading checkbox column appears; the header checkbox selects every row, and a bulk-actions bar is shown while rows are selected. Fill it through the bulk-actions slot, which receives the selected rows and a clear function. Pair it with toCsv + downloadCsv to export the selection — the demo's Export button does exactly that.

Selection is controlled. DataTable owns no selection state of its own: every toggle emits update:selection with the complete new map, and the parent writes it back. Keep the map accumulated across pages, filters, and sorts — carry the previous map forward (merge the toggle) rather than replacing it with only the visible rows, or earlier selections are lost. The "preserves earlier-page selections in server-side mode" test pins this.

manual mode is page-scoped. With manual (server-side data), the header checkbox and toggleAllRowsSelected operate on the rows in the current page — the row model — not on every matching record. To offer "select all N records", track that intent in the parent (for example a selectAll flag sent to the server) rather than relying on the checkbox.

Amina FaroukCardiology
Youssef KamalNeurology
Salma NabilOncology
vue
<script setup lang="ts">
import { computed, ref } from 'vue'
import { createColumnHelper } from '@tanstack/vue-table'
import { Button, DataTable, downloadCsv, toCsv, type DataTableFeatures } from '@myghf/ui'

interface Referral {
  id: string
  patient: string
  unit: string
}

const data: Referral[] = [
  { id: 'r1', patient: 'Amina Farouk', unit: 'Cardiology' },
  { id: 'r2', patient: 'Youssef Kamal', unit: 'Neurology' },
  { id: 'r3', patient: 'Salma Nabil', unit: 'Oncology' },
]

const columnHelper = createColumnHelper<DataTableFeatures, Referral>()
const columns = columnHelper.columns([
  columnHelper.accessor('patient', { header: 'Patient' }),
  columnHelper.accessor('unit', { header: 'Unit' }),
])
const getRowId = (row: Referral) => row.id

const selection = ref<Record<string, boolean>>({})
const selectedRecords = computed(() => data.filter((row) => selection.value[row.id]))

function exportSelection() {
  const csv = toCsv<Referral>(
    [
      { id: 'patient', header: 'Patient' },
      { id: 'unit', header: 'Unit' },
    ],
    selectedRecords.value,
  )
  downloadCsv('referrals.csv', csv)
}
</script>

<template>
  <DataTable
    v-model:selection="selection"
    :data="data"
    :columns="columns"
    :get-row-id="getRowId"
    selectable
  >
    <template #bulk-actions="{ rows, clear }">
      <Button size="sm" variant="outline" @click="clear">Clear</Button>
      <Button size="sm" variant="outline" @click="exportSelection">Export</Button>
      <Button size="sm">Archive {{ rows.length }}</Button>
    </template>
  </DataTable>
</template>

Error state ​

Set error to a message and DataTable replaces the body with it (use the error slot for custom content). The loading state still wins while loading is true.

Searching and filters ​

searchable renders a global search input, bound with v-model:global-filter. Per-column filters are a ColumnFiltersState bound with v-model:filters — every active filter shows as a removable chip in the toolbar, with a Clear filters button. When rows are filtered out the empty state switches to noResultsLabel. Use the toolbar slot to add your own controls (e.g. a per-column filter select).

  • Unit: Cardiology
Amina FaroukCardiology
Salma NabilCardiology
vue
<script setup lang="ts">
import { ref } from 'vue'
import { createColumnHelper, type ColumnFiltersState } from '@tanstack/vue-table'
import { DataTable, type DataTableFeatures } from '@myghf/ui'

interface Referral {
  id: string
  patient: string
  unit: string
}

const data: Referral[] = [
  { id: 'r1', patient: 'Amina Farouk', unit: 'Cardiology' },
  { id: 'r2', patient: 'Youssef Kamal', unit: 'Neurology' },
  { id: 'r3', patient: 'Salma Nabil', unit: 'Cardiology' },
  { id: 'r4', patient: 'Omar Hatem', unit: 'Oncology' },
]

const columnHelper = createColumnHelper<DataTableFeatures, Referral>()
const columns = columnHelper.columns([
  columnHelper.accessor('patient', { header: 'Patient' }),
  columnHelper.accessor('unit', { header: 'Unit' }),
])
const getRowId = (row: Referral) => row.id

const globalFilter = ref('')
const filters = ref<ColumnFiltersState>([{ id: 'unit', value: 'Cardiology' }])
</script>

<template>
  <DataTable
    v-model:global-filter="globalFilter"
    v-model:filters="filters"
    :data="data"
    :columns="columns"
    :get-row-id="getRowId"
    searchable
    search-placeholder="Search patients…"
  />
</template>

Column visibility, order, pinning, and resizing ​

Three pieces of column state are bound with v-model: column-visibility (id → visible), column-order (ids), and column-pinning ({ start, end }, logical so it mirrors under RTL — pinned cells stick with inset-inline-start/inset-inline-end). Set resizable to show drag handles on each header. Build the controls in the toolbar slot (the demo toggles a column and pins another).

Amina FaroukCardiology3
Youssef KamalNeurology12
Salma NabilOncology7
vue
<script setup lang="ts">
import { ref } from 'vue'
import { createColumnHelper, type ColumnPinningState } from '@tanstack/vue-table'
import { Checkbox, DataTable, type DataTableFeatures } from '@myghf/ui'

interface Referral {
  id: string
  patient: string
  unit: string
  waiting: number
}

const data: Referral[] = [
  { id: 'r1', patient: 'Amina Farouk', unit: 'Cardiology', waiting: 3 },
  { id: 'r2', patient: 'Youssef Kamal', unit: 'Neurology', waiting: 12 },
  { id: 'r3', patient: 'Salma Nabil', unit: 'Oncology', waiting: 7 },
]

const columnHelper = createColumnHelper<DataTableFeatures, Referral>()
const columns = columnHelper.columns([
  columnHelper.accessor('patient', { header: 'Patient', size: 200 }),
  columnHelper.accessor('unit', { header: 'Unit', size: 160 }),
  columnHelper.accessor('waiting', { header: 'Waiting (days)', size: 140, meta: { align: 'end' } }),
])
const getRowId = (row: Referral) => row.id

const visibility = ref<Record<string, boolean>>({})
const pinning = ref<ColumnPinningState>({ start: [], end: [] })
</script>

<template>
  <DataTable
    v-model:column-visibility="visibility"
    v-model:column-pinning="pinning"
    :data="data"
    :columns="columns"
    :get-row-id="getRowId"
    resizable
  >
    <template #toolbar>
      <label class="flex items-center gap-1.5 text-xs text-muted">
        <Checkbox
          :model-value="visibility.waiting !== false"
          @update:model-value="(value) => (visibility.waiting = Boolean(value))"
        />
        Waiting column
      </label>
      <label class="flex items-center gap-1.5 text-xs text-muted">
        <Checkbox
          :model-value="pinning.start?.includes('patient') ?? false"
          @update:model-value="(value) => (pinning.start = value ? ['patient'] : [])"
        />
        Pin patient
      </label>
    </template>
  </DataTable>
</template>

Responsive columns ​

Give a column meta: { hideBelow } and it hides while the viewport is narrower than that screen — Tailwind semantics, so hideBelow: 'md' hides below 768px:

ts
columnHelper.accessor('waiting', {
  header: 'Waiting (days)',
  meta: { hideBelow: 'md' }, // 'sm' | 'md' | 'lg' | 'xl' | '2xl'
})

The breakpoint never writes into v-model:column-visibility: viewport hiding is merged inside the table, and update:columnVisibility reports only your own changes. Above the breakpoint (e.g. desktop, and the first SSR render, where width is unknown until mount) every column is normal again. Columns you already hid through column-visibility are not surfaced by the breakpoint.

Below the breakpoint the hidden values stay reachable through a row disclosure: each row gains the leading expander button — the same one expandable renders, labelled with expandRowLabel — and its expansion row lists the hidden columns as a <dl> of labels and values (values go through your cell-<columnId> slots when present). With expandable set, the list renders above your expansion slot content in the same row.

meta keyTypeDescription
hideBelow'sm' | 'md' | 'lg' | 'xl' | '2xl'Hide this column while the viewport is narrower than that screen.
Amina FaroukCardiology3
Youssef KamalNeurology12
Salma NabilOncology7
vue
<script setup lang="ts">
import { ref } from 'vue'
import { createColumnHelper } from '@tanstack/vue-table'
import { DataTable, type DataTableFeatures } from '@myghf/ui'

interface Referral {
  id: string
  patient: string
  unit: string
  waiting: number
}

const data: Referral[] = [
  { id: 'r1', patient: 'Amina Farouk', unit: 'Cardiology', waiting: 3 },
  { id: 'r2', patient: 'Youssef Kamal', unit: 'Neurology', waiting: 12 },
  { id: 'r3', patient: 'Salma Nabil', unit: 'Oncology', waiting: 7 },
]

const columnHelper = createColumnHelper<DataTableFeatures, Referral>()
const columns = columnHelper.columns([
  columnHelper.accessor('patient', { header: 'Patient', size: 200 }),
  columnHelper.accessor('unit', {
    header: 'Unit',
    size: 160,
    meta: { hideBelow: 'sm' },
  }),
  columnHelper.accessor('waiting', {
    header: 'Waiting (days)',
    size: 140,
    meta: { hideBelow: 'md' },
  }),
])
const getRowId = (row: Referral) => row.id
const expanded = ref<Record<string, boolean>>({})
</script>

<template>
  <DataTable
    v-model:expanded="expanded"
    :data="data"
    :columns="columns"
    :get-row-id="getRowId"
  />
</template>

Resize below 768px to collapse Waiting (days) into the row disclosures, and below 640px to collapse Unit as well.

Header and cell alignment ​

Set meta.align on a column to align its header and that column's cells. The value maps to logical properties (text-start / text-center / text-end), so it mirrors automatically under RTL:

ts
columnHelper.accessor('waiting', {
  header: 'Waiting (days)',
  meta: { align: 'end' },
})
meta keyTypeDefaultDescription
align'start' | 'center' | 'end''start'Text alignment for the column's header and cells.

Sortable headers stay clickable when aligned — the sort button lines up with the aligned text. The columns demo end-aligns Waiting (days).

Pagination and server-side mode ​

Set paginate to render the pagination footer (bound with v-model:page-index / v-model:page-size) over the client-side rows. For large datasets set manual instead: TanStack skips client sorting/filtering/pagination, rowCount supplies the server total, and you refetch on update:pageIndex, update:pageSize, update:sorting, and update:filters. The pagination slot replaces the default footer.

vue
<DataTable
  v-model:page-index="pageIndex"
  v-model:page-size="pageSize"
  :data="rows"
  :columns="columns"
  :get-row-id="getRowId"
  :row-count="total"
  manual
/>
Patient 1Cardiology
Patient 2Neurology
Patient 3Oncology
Patient 4Paediatrics
Patient 5Cardiology
Rows per page
1–5 of 12
vue
<script setup lang="ts">
import { ref } from 'vue'
import { createColumnHelper } from '@tanstack/vue-table'
import { DataTable, type DataTableFeatures } from '@myghf/ui'

interface Referral {
  id: string
  patient: string
  unit: string
}

const units = ['Cardiology', 'Neurology', 'Oncology', 'Paediatrics']
const data: Referral[] = Array.from({ length: 12 }, (_, index) => ({
  id: `r${index + 1}`,
  patient: `Patient ${index + 1}`,
  unit: units[index % units.length],
}))

const columnHelper = createColumnHelper<DataTableFeatures, Referral>()
const columns = columnHelper.columns([
  columnHelper.accessor('patient', { header: 'Patient' }),
  columnHelper.accessor('unit', { header: 'Unit' }),
])
const getRowId = (row: Referral) => row.id

const pageIndex = ref(0)
const pageSize = ref(5)
</script>

<template>
  <DataTable
    v-model:page-index="pageIndex"
    v-model:page-size="pageSize"
    :data="data"
    :columns="columns"
    :get-row-id="getRowId"
    paginate
  />
</template>

Virtual scrolling ​

For very large datasets set maxHeight and virtual together: DataTable renders only the visible slice (plus a small overscan) and pads the rest with spacer rows, so the DOM stays small however many rows you pass. It assumes a uniform rowHeight (default 40) and does not account for expansion rows, so use it with flat rows.

vue
<DataTable :data="rows" :columns="columns" :get-row-id="getRowId" max-height="24rem" virtual />

DataTableFeatures ​

columns is typed against DataTableFeatures, the feature set registered in src/lib/table.ts and re-exported from @myghf/ui. It enables exactly three TanStack features:

FeatureWhat it adds
rowSortingFeature (+ sortedRowModel, sortFns)Sortable columns and the update:sorting state.
rowPaginationFeature (+ paginatedRowModel)Pagination state. DataTable renders the footer when paginate (or manual) is set; otherwise reach the row model by composing TanStack directly with DataTableFeatures.
rowExpandingFeature (+ expandedRowModel)Per-row expansion driven by the expanded map.
rowSelectionFeaturePer-row selection, select-all, and the bulk-actions bar.
columnFilteringFeature (+ filteredRowModel, filterFns)Per-column filters, the toolbar chips, and update:filters.
globalFilteringFeatureThe global search term and update:globalFilter.
columnVisibilityFeatureColumn visibility and update:columnVisibility.
columnOrderingFeatureColumn order and update:columnOrder.
columnPinningFeatureLogical start/end pinning and update:columnPinning.
columnSizingFeature + columnResizingFeatureColumn sizes and the drag-to-resize handles.

TanStack v9 tree-shakes anything not registered, so features outside this list — column grouping — are not available through DataTable. Use it when you need exactly this set; otherwise compose Table yourself.

columns has the type ColumnDef<typeof dataTableFeatures, T>[], so author them with createColumnHelper<DataTableFeatures, T>() from @tanstack/vue-table. A column's numeric size is read structurally and used as the column (header) width. Column meta is typed through the feature set's columnMeta slot — hideBelow (see Responsive columns) and align (see Header and cell alignment), with the DataTableColumnMeta / DataTableHideBelow types exported from @myghf/ui.

Props ​

PropTypeDefaultDescription
dataT[]— (required)Row data.
columnsColumnDef<DataTableFeatures, T>[]— (required)Column definitions.
getRowId(row: T) => string—Stable row id, used for keys and the expansion map. Strongly recommended.
stripedbooleanfalseShades every even body row.
size'sm' | 'default''default'Compact or default text size.
emptyLabelstring'No results'Message shown when there are no rows.
sortablebooleantrueRenders clicking/sorting headers for columns that can sort.
sortingSortingState—Active sort. Uncontrolled unless bound — bind with v-model:sorting to own it in the parent.
expandablebooleanfalseMakes rows toggle a detail row.
expandedRecord<string, boolean>{}Expansion map keyed by row id. Bind with v-model:expanded.
stopRowToggleOnInteractiveCellsbooleantrueKeeps clicks on buttons/links/inputs from also toggling the row.
maxHeightstring—When set, makes the wrapper scroll vertically at this height.
loadingbooleanfalseRenders placeholder skeleton rows instead of the data rows. Sets aria-busy="true" on the wrapper and suppresses the empty state.
loadingRowsnumber5Number of placeholder rows shown while loading.
loadingLabelstring'Loading…'Screen-reader-only text announced as the loading status.
selectablebooleanfalseRenders a leading checkbox column and the bulk-actions bar.
selectionRecord<string, boolean>{}Selected-row map keyed by row id. Bind with v-model:selection.
selectAllLabelstring'Select all rows'Accessible name for the header checkbox.
selectRowLabelstring'Select row'Accessible-name prefix for each row checkbox (the row number is appended).
selectedLabelstring'selected'Word following the count in the bulk-actions bar.
errorstring—Error message. Replaces the body unless loading is set.
expandRowLabelstring'Toggle row'Accessible-name prefix for each row's expander button (the row number is appended).
searchablebooleanfalseRenders a global search input in the toolbar.
searchPlaceholderstring'Search…'Placeholder for the search input.
searchLabelstring'Search'Accessible name for the search input.
globalFilterstring''Global filter term. Bind with v-model:global-filter.
filtersColumnFiltersState[]Per-column filters. Bind with v-model:filters.
noResultsLabelstring'No results match your filters'Empty-state text shown while a filter is active.
clearFiltersLabelstring'Clear filters'Toolbar button that clears all filters.
columnVisibilityRecord<string, boolean>{}Column visibility by id. Bind with v-model:column-visibility.
columnOrderstring[][]Column order (ids). Bind with v-model:column-order.
columnPinning{ start?: string[]; end?: string[] }{ start: [], end: [] }Pinned columns (logical). Bind with v-model:column-pinning.
resizablebooleanfalseRender drag handles to resize columns.
manualbooleanfalseServer-side mode: skip client sorting/filtering/pagination.
paginatebooleanfalseRender the pagination footer.
pageIndexnumber0Current page (0-based). Bind with v-model:page-index.
pageSizenumber10Rows per page. Bind with v-model:page-size.
rowCountnumber0Total rows across all pages (server-side).
pageSizeOptionsnumber[][5, 10, 20]Page-size choices in the footer.
virtualbooleanfalseWindow the rows (requires maxHeight). Assumes uniform row height.
rowHeightnumber40Assumed height of one data row, in pixels, when virtual.

Events ​

EventPayloadDescription
update:sorting{ id: string; desc: boolean }[]Emitted whenever the sort state changes.
update:expandedRecord<string, boolean>Emitted with the new expansion map.
update:selectionRecord<string, boolean>Emitted with the new selection map.
update:globalFilterstringEmitted with the new global filter term.
update:filtersColumnFiltersStateEmitted with the new per-column filters.
update:columnVisibilityRecord<string, boolean>Emitted with the new visibility map. Breakpoint-forced hiding (Responsive columns) is merged inside the table and never appears here.
update:columnOrderstring[]Emitted with the new column order.
update:columnPinning{ start?: string[]; end?: string[] }Emitted with the new pinning state.
update:pageIndexnumberEmitted when the page changes.
update:pageSizenumberEmitted when the page size changes.
row-clickunknownEmitted with the clicked row's original data. Fires even when expandable is false.

Slots ​

SlotPropsDescription
empty—Replaces emptyLabel when there are no rows.
cell-<columnId>{ row, cell, value }Overrides that column's cell. The column id is its accessor key (or id).
expansion{ row }Content of the expansion row, shown for expanded rows only — after the responsive disclosure list, when one is active.
bulk-actions{ rows, clear }Content of the bulk-actions bar, shown while rows are selected.
error—Replaces the error text when error is set.
toolbar—Extra controls in the toolbar (next to the search input and chips).
pagination{ pageIndex, pageSize, total }Replaces the default pagination footer.

DataTable renders no default slot — all cells come from FlexRender or a cell-* slot.

Exposed methods ​

None. DataTable does not call defineExpose. Sort and expand through v-model bindings and the events above.

Accessibility ​

  • Sortable headers are real <button>s inside <th>, with the aria-sort state written by the underlying TableHead. Non-sortable headers render plain text. Keyboard users can focus and activate each sort button.
  • Expansion is toggled by clicking the row (TableRow gets clickable and data-state="expanded"), and by a leading expander button rendered when expandable. stopRowToggleOnInteractiveCells prevents a click on an interactive cell from also toggling the row. The expander is a real <button> with aria-expanded and an aria-label (expandRowLabel plus the row number), so expansion is keyboard reachable.
  • With expandable, the expansion row spans all columns and is revealed inline after the row it belongs to.
  • While loading, the wrapper carries aria-busy="true" and a sr-only element holds loadingLabel, so assistive technology hears a status without seeing the placeholder rows. Placeholder rows are inert — they carry no click handler and cannot expand.
  • The empty state renders a full-width TableEmpty row, so the table keeps its structure when there is no data. It is suppressed while loading, so an empty data array does not flash "No results" before the first rows arrive.
  • With selectable, the header and row checkboxes are real Checkbox controls with aria-labels (selectAllLabel, and selectRowLabel plus the row number), and aria-checked reflects the selection. Clicking them never toggles row expansion.
  • Responsive columns (see above) reuse that same expander button — aria-expanded, aria-label from expandRowLabel — so the disclosure is keyboard reachable, and the hidden values render as a semantic <dl> of dt/dd pairs.

Dark mode & RTL ​

  • DataTable renders through Table, so it inherits the same semantic tokens (bg-surface, border-border, bg-surface-muted) and adapts to dark mode. Expansion rows use bg-surface-muted/30.
  • Loading placeholders use Skeleton, whose bg-surface-muted fill is defined for both themes, so the loading state needs no extra dark-mode styles.
  • Sorting icons are Lucide chevrons, and the width is applied per column, so no physical direction is baked in. When maxHeight is set the wrapper adds an overflow-auto scroll region; the underlying table's logical text-start/text-end alignment mirrors correctly under dir="rtl".

Released under the MIT License.