Skip to content

Content

Table

Data table with Header, Body, Row, Column, and Cell parts.

import { Table } from '@var-ui/react';
NameRole
AdaAdmin
GraceEditor

Table

Presentational semantic <table> for admin data grids. Use compound Table.Header / Body / Row / Column / Cell parts or a data-driven columns + data API.

Examples

Default

A simple two-column data table.

NameRole
AdaAdmin
GraceEditor
Demo.tsxTSX
import { Table } from '@var-ui/react';

<Table
  columns={[
    { key: 'name', header: 'Name', rowHeader: true },
    { key: 'role', header: 'Role' },
  ]}
  data={[{ name: 'Ada', role: 'Admin' }]}
/>

Striped compact

Enable striped and density="compact" for denser rosters; add caption for an accessible table title.

Team roster
NameRoleStatus
AdaAdminActive
GraceEditorActive
AlanViewerInvited
KatherineEditorActive
Demo.tsxTSX
import { Table } from '@var-ui/react';

<Table
  striped
  density="compact"
  caption="Team roster"
  columns={[
    { key: 'name', header: 'Name', rowHeader: true },
    { key: 'role', header: 'Role' },
    { key: 'status', header: 'Status' },
  ]}
  data={[
    { name: 'Ada', role: 'Admin', status: 'Active' },
    { name: 'Grace', role: 'Editor', status: 'Active' },
  ]}
/>

Bordered, with a minimum width

bordered frames the table with an outer border and rounded corners. minWidth sets the <table>’s minimum width (any CSS min-width value): when the container is narrower, the table scrolls horizontally inside its frame instead of squeezing the columns. highlightOnHover shades the row under the pointer.

Recent runs
RunBranchStatusDurationStarted
#1284mainPassed4m 12s09:41
#1283feat/tableFailed2m 03s09:12
#1282mainPassed4m 08s08:57
Demo.tsxTSX
import { Table } from '@var-ui/react';

<Table
  bordered
  highlightOnHover
  minWidth="40rem"
  caption="Recent runs"
  columns={[
    { key: 'run', header: 'Run', rowHeader: true },
    { key: 'branch', header: 'Branch' },
    { key: 'status', header: 'Status' },
    { key: 'duration', header: 'Duration', align: 'end' },
    { key: 'started', header: 'Started', align: 'end' },
  ]}
  data={runs}
/>

Styling the table

className and style go to the root, the horizontal scroller that frames the table. Give it a maxHeight to scroll rows under a stickyHeader. ref and every other native attribute (aria-label, id, data-*) go to the <table>, the same split as the form fields. To size the table from CSS instead of the prop, set --var-ui-table-minwidth on the root or in a theme.

Props

Accessibility

Renders a real <table>. Mark the identifying column with rowHeader (scope="row"). Prefer a caption (or external heading referenced with aria-labelledby) so the table has an accessible name. Sort chrome sets aria-sort when you wire allowsSorting / onSortChange.