Tac UIv1.1.2

Table

A composable table component for displaying structured tabular data.

Import

tsx
import { Table, TableHeader, TableBody, TableFooter, TableRow, TableHead, TableCell, TableCaption } from '@tac-ui/web';

Basic

A minimal table using TableHeader, TableBody, TableRow, TableHead, and TableCell. Rows gain a hover highlight by default.

NameRoleEmail
Alice MartinEngineer[email protected]
Bob ChenDesigner[email protected]
Carol WhiteProduct[email protected]
David KimEngineer[email protected]
tsx
<Table>
  <TableHeader>
    <TableRow>
      <TableHead>Name</TableHead>
      <TableHead>Role</TableHead>
      <TableHead>Email</TableHead>
    </TableRow>
  </TableHeader>
  <TableBody>
    <TableRow>
      <TableCell>Alice Martin</TableCell>
      <TableCell>Engineer</TableCell>
      <TableCell>[email protected]</TableCell>
    </TableRow>
    {/* ...more rows */}
  </TableBody>
</Table>

Invoice Example

A complete table with header, body, footer for totals, a caption, and status badges — demonstrating all subcomponents together.

Recent invoices — Q1 2025
InvoiceClientDateStatusAmount
INV-001Acme CorpJan 12, 2025Paid$1,250.00
INV-002Globex IncJan 18, 2025Pending$850.00
INV-003InitechJan 22, 2025Failed$3,400.00
INV-004Umbrella LtdFeb 01, 2025Paid$620.00
INV-005HooliFeb 05, 2025Pending$2,100.00
Total$8,220.00
tsx
<Table>
  <TableCaption>Recent invoices — Q1 2025</TableCaption>
  <TableHeader>
    <TableRow>
      <TableHead>Invoice</TableHead>
      <TableHead>Client</TableHead>
      <TableHead>Date</TableHead>
      <TableHead>Status</TableHead>
      <TableHead className="text-right">Amount</TableHead>
    </TableRow>
  </TableHeader>
  <TableBody>
    <TableRow>
      <TableCell>INV-001</TableCell>
      <TableCell>Acme Corp</TableCell>
      <TableCell>Jan 12, 2025</TableCell>
      <TableCell><Badge variant="success">Paid</Badge></TableCell>
      <TableCell className="text-right">$1,250.00</TableCell>
    </TableRow>
    {/* ...more rows */}
  </TableBody>
  <TableFooter>
    <TableRow>
      <TableCell colSpan={4}>Total</TableCell>
      <TableCell className="text-right">$8,220.00</TableCell>
    </TableRow>
  </TableFooter>
</Table>

With Caption

TableCaption renders an accessible caption below the table, useful for labeling the data context.

Team members — Engineering
NameRole
Alice MartinEngineer
Bob ChenDesigner
tsx
<Table>
  <TableCaption>Team members — Engineering</TableCaption>
  <TableHeader>
    <TableRow>
      <TableHead>Name</TableHead>
      <TableHead>Role</TableHead>
    </TableRow>
  </TableHeader>
  <TableBody>
    <TableRow>
      <TableCell>Alice Martin</TableCell>
      <TableCell>Engineer</TableCell>
    </TableRow>
  </TableBody>
</Table>

API Reference

All subcomponents accept standard HTML element attributes (className, style, etc.) and forward their ref to the underlying DOM element.

PropTypeDefaultDescription
TableReact.HTMLAttributes<HTMLTableElement>-Root table element wrapped in a horizontally-scrollable container.
TableHeaderReact.HTMLAttributes<HTMLTableSectionElement>-Renders <thead>. Applies a subtle background and border-bottom to its rows.
TableBodyReact.HTMLAttributes<HTMLTableSectionElement>-Renders <tbody>. Removes the border from the last row automatically.
TableFooterReact.HTMLAttributes<HTMLTableSectionElement>-Renders <tfoot> with a top border and secondary background for totals or summaries.
TableRowReact.HTMLAttributes<HTMLTableRowElement>-Renders <tr> with hover highlight. Applies selected styling when data-state="selected".
TableHeadReact.ThHTMLAttributes<HTMLTableCellElement>-Renders <th scope="col"> with muted foreground text and medium font weight.
TableCellReact.TdHTMLAttributes<HTMLTableCellElement>-Renders <td> with standard padding and middle vertical alignment.
TableCaptionReact.HTMLAttributes<HTMLTableCaptionElement>-Renders <caption> positioned below the table in muted foreground text.