Table

Styled table primitives for structured data, with header, body, footer, row, cell and caption parts on native table elements.

import { Table, TableHeader, TableBody, TableRow, TableHead, TableCell } from "@plexui/vue/components/Table";
import { DataTable, DataTableColumnHeader } from "@plexui/vue/components/DataTable";

Table Primitives

Overview

Minimal

DataTable

The examples import users (15 rows) and its User type from a local ./data file. Column definitions live in <script setup>: header and cell renderers are functions that return VNodes (h()), rendered with TanStack Table's FlexRender.

Variant

variant

Sorting

Pagination

Row click

Row selection

Cell variants

Filtering

Column visibility

Empty state

API

Table Primitives

PropTypeDefaultDescription
Tabletable—Root table container with horizontal scroll wrapper; attributes go to the <table>
TableHeaderthead—Table header group
TableBodytbody—Table body group
TableFootertfoot—Table footer group
TableRowtr—Table row
TableHeadth—Table header cell
TableCelltd—Table data cell
TableCaptioncaption—Table caption

Every part renders its native element with the default slot as content, merges class after its own, and forwards all other attributes and listeners (colspan, scope, @click, ...).

DataTable

PropTypeDefaultDescription
columnsColumnDef<TData>[]—Column definitions following TanStack Table v8 API; header and cell renderers return VNodes (required)
dataTData[]—Data array to display (required)
variant"default" | "bordered""default"Visual variant: bordered adds a rounded border and tinted header
page-sizenumber10Rows per page. Set 0 or Infinity to disable pagination. The rows-per-page select offers 10, 20, 50, 100 and this size
initial-sortingSortingState—Initial column sorting state
global-filterstring—Controlled search/filter string. Bind with v-model:global-filter
column-visibilityVisibilityState—Controlled column visibility state. Bind with v-model:column-visibility
enable-row-selectionbooleanfalseAdds a first column (id select) with a checkbox per row and a header checkbox that selects every row on all pages, mixed when some are selected. A click on a checkbox is not a row click
row-selectionRowSelectionState—Controlled row selection state. Bind with v-model:row-selection
get-row-id(row: TData) => string—Custom row ID accessor; selection keys use it
empty-messagestring | number | VNode"No results."Shown when no rows; the emptyMessage slot takes precedence
show-paginationbooleantrueWhether to show pagination controls. They hide on their own when every row fits on one page
classstring—Class applied to outermost wrapper
emptyMessage slotVNode[]—Rich content shown when no rows
@row-click(row: TData) => void—Click handler for rows. Makes rows interactive: they take Tab and call it on Enter or Space
@update:global-filter(value: string) => void—Emitted with the next filter when the table changes it; powers v-model:global-filter
@update:column-visibility(visibility: VisibilityState) => void—Emitted with the next visibility; powers v-model:column-visibility
@update:row-selection(selection: RowSelectionState) => void—Emitted with the next selection; powers v-model:row-selection

@row-click is a function prop rather than an event, because its presence makes the rows interactive; :on-row-click works the same. Column groups (a column definition with columns) render a header that spans its columns.

DataTableColumnHeader

PropTypeDefaultDescription
columnColumn<TData, TValue>—TanStack Table column object (required)
titlestring—Display text for the header (required)
classstring—Class applied to the header button (or text when the column cannot sort)

Column helpers

PropTypeDefaultDescription
idCell(accessor)CellComponent—Monospace ID with copy-on-click tooltip
dateTimeCell(accessor, options?)CellComponent—Formatted datetime with Intl.DateTimeFormat
statusCell(accessor, colorMap?)CellComponent—Badge cell with automatic status-to-color mapping
tooltipHeader(label, description)HeaderComponent—Header with dashed underline and info tooltip

Each helper returns a functional component for a column's cell or header; TanStack Table's FlexRender renders it with the cell or header context.

Styling

Table reads these component tokens. Override them at any scope to restyle it:

  • --table-border-color: border color (default var(--color-border))
  • --table-caption-color: caption color (default var(--color-text-tertiary))
  • --table-caption-font-size: caption font size (default var(--font-text-sm-size))
  • --table-cell-color: cell color (default var(--color-text))
  • --table-cell-font-size: cell font size (default var(--font-text-sm-size))
  • --table-cell-line-height: cell line height (default var(--font-text-sm-line-height))
  • --table-cell-padding: cell padding (default spacing(3) spacing(4))
  • --table-footer-background: footer background (default transparent)
  • --table-footer-font-weight: footer font weight (default var(--font-weight-medium))
  • --table-header-background: header background (default transparent)
  • --table-header-color: header color (default var(--color-text-secondary))
  • --table-header-font-weight: header font weight (default var(--font-weight-medium))
  • --table-row-hover-background: row hover background (default light-dark(var(--alpha-02), var(--alpha-04)))