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 | Region | Uptime |
|---|---|---|
| API Gateway | eu-central | 99.98% |
| Auth Worker | us-east | 99.95% |
| Realtime Hub | ap-south | 99.99% |
VdDataTable
Sortable headers expose aria-sort. columns.variant tints headers here (not on VdTable). Search is client-side unless :manual.
AL Ada Lovelace | Admin | Active | 3 | |
GH Grace Hopper | Editor | Active | 2 | |
AT Alan Turing | Viewer | Pending | 1 | |
KJ Katherine Johnson | Editor | Active | 2 | |
DV Dorothy Vaughan | Viewer | Paused | 1 |
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.
| Ada Lovelace | Admin | Active | 3 |
| Grace Hopper | Editor | Active | 2 |
| Alan Turing | Viewer | Pending | 1 |
| Katherine Johnson | Editor | Active | 2 |
Bordered Table
| Name | Role | |
|---|---|---|
| John Doe | john@example.com | Admin |
| Jane Smith | jane@example.com | User |
| Mike Johnson | mike@example.com | User |
Striped Table
| Product | Price | Stock |
|---|---|---|
| Product A | $29.99 | 50 |
| Product B | $39.99 | 30 |
| Product C | $49.99 | 20 |
Hover Table
| ID | Status | Date |
|---|---|---|
| #001 | Active | 2024-01-15 |
| #002 | Pending | 2024-01-16 |
| #003 | Failed | 2024-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 Name | Description | Type |
|---|---|---|
.vd-table | Base component class required for all VD3 UI tables. | Component |
.vd-table-bordered | Modifier class that adds borders to all outer boundaries and internal cells. | Modifier |
.vd-table-striped | Modifier class that adds alternating background colors to body rows (zebra striping). | Modifier |
.vd-table-hover | Modifier class that enables a hover background color effect on body rows. | Modifier |
.vd-table-responsive | Wrapper class that enables horizontal scrolling on small screens. | Layout |
.vd-data-table | Interactive grid chrome wrapping .vd-table (toolbar, sticky header, footer). | Component |
.vd-empty | Reusable empty-state stack (icon, title, description, action). | Component |
VdTable API (Vue 3)
| Prop | Description |
|---|---|
:columns | Array of { key, label }. Optional variant is typed but not applied — VdTable is presentational markup. |
:rows | Array of plain row objects keyed by each column's key. |
:striped | Zebra row striping. |
:bordered | Cell borders. |
:hover | Row hover highlight. |
:caption | Accessible table caption. |
VdDataTable API (Vue 3)
| Prop / slot / event | Description |
|---|---|
:columns | { key, label, sortable?, align?, width?, variant? }. variant adds vd-table-{variant} on the header cell. |
:rows | Row objects. Apps own fetch; pass already-sliced rows with :manual. |
:row-key | String 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:page | Controlled sort, selection, page. |
:searchable / :search-keys / :search-placeholder | Toolbar VdInput filters client-side unless :manual. |
:page-size / :manual / :loading | Paging; skip client pipeline; skeleton rows. |
:empty-title / :empty-description / :max-height | Empty copy; sticky-header scrollport. |
:striped / :bordered / :hover / :sm / :caption | Same visual language as VdTable. |
#cell-{key} / #header-{key} / #toolbar / #empty / #loading / #footer | Cell/header overrides plus chrome. Default footer is VdPagination (total = page count). |
@row-click | Fired with the row object. |
useTableState(options) Composable API
| Option / Return Member | Description |
|---|---|
options.rows | Ref<readonly T[]> | (() => readonly T[]) — source row array. |
options.getRowId | (row: T, index: number) => string — unique row identifier resolver. |
options.pageSize | Ref<number> | number (default 10) — rows per page in client mode. |
options.searchKeys | readonly string[] | Ref<readonly string[] | undefined> | (() => readonly string[] | undefined) — keys to match against search query (defaults to all row values). |
options.manual | Ref<boolean> | boolean (default false) — bypasses client filter/sort/slice when rows are already paginated server-side. |
viewRows / total / totalPages | Ref<T[]> of current page rows, Ref<number> filtered row count, and Ref<number> total page count. |
page / search / sort | Reactive 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 / someVisibleSelected | Computed Ref<boolean> flags for header select-all checkbox checked and indeterminate states. |
VdEmptyState API (Vue 3)
| Prop / slot | Description |
|---|---|
:icon | Phosphor icon name. |
:title / :description | Heading and supporting copy. |
#action | Optional call-to-action slot. |
Accessibility
VdTableandVdDataTablerender semantic<table>,<caption>, and<th scope="col">header cells.- Sortable column headers in
VdDataTableuse<button type="button">triggers and exposearia-sort="ascending" | "descending" | "none"on the parent<th>. - Row selection checkboxes and the header select-all checkbox provide explicit
aria-labelattributes (e.g."Select all rows"and"Select row {id}") along with indeterminate state support.