Tables

Presentational VdTable (CSS table) plus VdDataTable — client search, sort, selection, and paging via useTableState. Apps own fetch. Cell slots compose VdAvatar / VdBadge; a dashboard recipe can sit a VdChart above the grid. useTableState takes rows, getRowId, pageSize, searchKeys, and manual, and returns viewRows, total, totalPages, page, search, sort, selectedIds, toggle, toggleAll, allVisibleSelected, and someVisibleSelected.

VdTable (Presentational)

Lightweight presentational wrapper that renders a responsive .vd-table with optional striped, bordered, hover, and caption props.

Service status overview
ServiceRegionUptime
API Gatewayeu-central99.98%
Auth Workerus-east99.95%
Realtime Hubap-south99.99%
VdDataTable

Sortable headers expose aria-sort. columns.variant tints headers here (not on VdTable). Search is client-side unless :manual.

Team
Ada LovelaceAdminActive3
Grace HopperEditorActive2
Alan TuringViewerPending1
Katherine JohnsonEditorActive2
Dorothy VaughanViewerPaused1

Selected: none

Empty state

No teammates yet

Invite someone to populate this grid.

Dashboard recipe

Composition only — charts come from @vanduo-oss/vd3-charts; the table stays in VD3 UI.

Same rows, denser page
Ada LovelaceAdminActive3
Grace HopperEditorActive2
Alan TuringViewerPending1
Katherine JohnsonEditorActive2
Bordered Table
NameEmailRole
John Doejohn@example.comAdmin
Jane Smithjane@example.comUser
Mike Johnsonmike@example.comUser
Striped Table
ProductPriceStock
Product A$29.9950
Product B$39.9930
Product C$49.9920
Hover Table
IDStatusDate
#001Active2024-01-15
#002Pending2024-01-16
#003Failed2024-01-17
Usage
<script setup lang="ts">
import { VdAvatar, VdDataTable, VdTable } from "@vanduo-oss/vd3";

const columns = [
  { key: "name", label: "Name", sortable: true },
  { key: "status", label: "Status", variant: "success" },
];
const rows = [{ id: "1", name: "Build", status: "Passing", initials: "B" }];
</script>

<template>
  <!-- Presentational CSS table — columns.variant is unused here -->
  <VdTable :columns="columns" :rows="rows" striped hover caption="CI status" />

  <!-- Interactive grid — variant applies vd-table-{variant} on headers -->
  <VdDataTable
    :columns="columns"
    :rows="rows"
    row-key="id"
    searchable
    selectable="multiple"
    striped
    hover
    caption="Team"
  >
    <template #cell-name="{ row }">
      <VdAvatar :initials="row.initials" size="sm" />
      {{ row.name }}
    </template>
  </VdDataTable>
</template>
CSS Classes
Class NameDescriptionType
.vd-tableBase component class required for all VD3 UI tables.Component
.vd-table-borderedModifier class that adds borders to all outer boundaries and internal cells.Modifier
.vd-table-stripedModifier class that adds alternating background colors to body rows (zebra striping).Modifier
.vd-table-hoverModifier class that enables a hover background color effect on body rows.Modifier
.vd-table-responsiveWrapper class that enables horizontal scrolling on small screens.Layout
.vd-data-tableInteractive grid chrome wrapping .vd-table (toolbar, sticky header, footer).Component
.vd-emptyReusable empty-state stack (icon, title, description, action).Component
VdTable API (Vue 3)
PropDescription
:columnsArray of { key, label }. Optional variant is typed but not applied — VdTable is presentational markup.
:rowsArray of plain row objects keyed by each column's key.
:stripedZebra row striping.
:borderedCell borders.
:hoverRow hover highlight.
:captionAccessible table caption.
VdDataTable API (Vue 3)
Prop / slot / eventDescription
:columns{ key, label, sortable?, align?, width?, variant? }. variant adds vd-table-{variant} on the header cell.
:rowsRow objects. Apps own fetch; pass already-sliced rows with :manual.
:row-keyString key or (row, index) => id (default 'id').
:selectable'none' | 'single' | 'multiple'. Row + select-all checkboxes are labelled.
v-model:sort / v-model:selected / v-model:pageControlled sort, selection, page.
:searchable / :search-keys / :search-placeholderToolbar VdInput filters client-side unless :manual.
:page-size / :manual / :loadingPaging; skip client pipeline; skeleton rows.
:empty-title / :empty-description / :max-heightEmpty copy; sticky-header scrollport.
:striped / :bordered / :hover / :sm / :captionSame visual language as VdTable.
#cell-{key} / #header-{key} / #toolbar / #empty / #loading / #footerCell/header overrides plus chrome. Default footer is VdPagination (total = page count).
@row-clickFired with the row object.
useTableState(options) Composable API
Option / Return MemberDescription
options.rowsRef<readonly T[]> | (() => readonly T[]) — source row array.
options.getRowId(row: T, index: number) => string — unique row identifier resolver.
options.pageSizeRef<number> | number (default 10) — rows per page in client mode.
options.searchKeysreadonly string[] | Ref<readonly string[] | undefined> | (() => readonly string[] | undefined) — keys to match against search query (defaults to all row values).
options.manualRef<boolean> | boolean (default false) — bypasses client filter/sort/slice when rows are already paginated server-side.
viewRows / total / totalPagesRef<T[]> of current page rows, Ref<number> filtered row count, and Ref<number> total page count.
page / search / sortReactive controls: page (Ref<number>), search (Ref<string>), and sort (Ref<{ key: string, dir: 'asc' | 'desc' | 'none' }>).
selectedIds / toggle(id) / toggleAll()Selection state (Ref<string[]>) and helpers to toggle one row or all visible rows.
allVisibleSelected / someVisibleSelectedComputed Ref<boolean> flags for header select-all checkbox checked and indeterminate states.
VdEmptyState API (Vue 3)
Prop / slotDescription
:iconPhosphor icon name.
:title / :descriptionHeading and supporting copy.
#actionOptional call-to-action slot.
Accessibility
  • VdTable and VdDataTable render semantic <table>, <caption>, and <th scope="col"> header cells.
  • Sortable column headers in VdDataTable use <button type="button"> triggers and expose aria-sort="ascending" | "descending" | "none" on the parent <th>.
  • Row selection checkboxes and the header select-all checkbox provide explicit aria-label attributes (e.g. "Select all rows" and "Select row {id}") along with indeterminate state support.