Trivela UI

Table

A table composed from parts that map one-to-one onto the HTML elements, with four looks and color token support.

Every part renders its own element, so the markup you write is the markup you get: TableHeader is <thead>, TableHead is <th>, and TableData is <td>. Table stays a bare <table> rather than wrapping itself in a scroll container — see Scrollable.

variant and color live on Table alone; the parts draw nothing themselves, so the look has exactly one source of truth. Table is also the only component whose variants are not solid/ghost/outline/subtle — those names describe nothing useful about a table.
NameRole
Jane DoeAdmin
Alex StoneEditor

Usage

table-demo.tsx
import {
  Table, TableHeader, TableBody, TableRow, TableHead, TableData,
} from 'trivela-ui';

export function Example() {
  return (
    <Table>
      <TableHeader>
        <TableRow>
          <TableHead>Name</TableHead>
          <TableHead>Role</TableHead>
        </TableRow>
      </TableHeader>
      <TableBody>
        <TableRow>
          <TableData>Jane Doe</TableData>
          <TableData>Admin</TableData>
        </TableRow>
      </TableBody>
    </Table>
  );
}

Examples

Variants

Four looks. Hover any body row — the tint follows the color token, and on a striped table it still wins over the stripe.

default

NameRoleAmount
Jane DoeAdmin$120.00
Alex StoneEditor$80.00
Mia KernViewer$40.00

striped

NameRoleAmount
Jane DoeAdmin$120.00
Alex StoneEditor$80.00
Mia KernViewer$40.00

bordered

NameRoleAmount
Jane DoeAdmin$120.00
Alex StoneEditor$80.00
Mia KernViewer$40.00

plain

NameRoleAmount
Jane DoeAdmin$120.00
Alex StoneEditor$80.00
Mia KernViewer$40.00

Colors

The color token tints the stripes, dividers, borders, and hover — all from one prop. It combines with any variant.

striped · primary

NameRole
Jane DoeAdmin
Alex StoneEditor
Mia KernViewer

striped · success

NameRole
Jane DoeAdmin
Alex StoneEditor
Mia KernViewer

striped · danger

NameRole
Jane DoeAdmin
Alex StoneEditor
Mia KernViewer

striped · info

NameRole
Jane DoeAdmin
Alex StoneEditor
Mia KernViewer

bordered · primary

NameRole
Jane DoeAdmin
Alex StoneEditor
Mia KernViewer

Anatomy

TableHeader draws the divider, TableBody drops the border off the last row, and TableRow tints on hover.

NameRoleStatus
Jane DoeAdminActive
Alex StoneEditorActive
Mia KernViewerInvited

With a caption

A caption names the table for screen readers with no ARIA at all. It must be the table's first child, so it renders above — add caption-bottom on Table to move it below.

Workspace members and their roles
NameRole
Jane DoeAdmin
Alex StoneEditor
Mia KernViewer

Row headers

TableHead works inside TableBody too. Give it scope="row" so screen readers announce the row's name with each cell.

NameRole
Jane DoeAdmin
Alex StoneEditor
Mia KernViewer

Scrollable on narrow screens

Table is w-full and does not wrap itself, so add an overflow container when the columns outgrow the space.

NameRoleStatusLast seen
Jane DoeAdminActive2 hours ago
Alex StoneEditorActive2 hours ago
Mia KernViewerInvited2 hours ago

API Reference

PropTypeDefaultDescription
variant'default' | 'striped' | 'bordered' | 'plain''default'Table only — the look. Not the shared solid/ghost/outline/subtle.
color'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'info' | 'neutral''neutral'Table only — tints the stripes, dividers, borders, and hover together.
classNamestringMerged with the generated classes via cn().
TableHTMLAttributes<HTMLTableElement><table>. w-full, border-collapse, text-left, text-sm.
TableHeaderHTMLAttributes<HTMLTableSectionElement><thead>. Structural only — the variant styles it.
TableBodyHTMLAttributes<HTMLTableSectionElement><tbody>. Structural only — the variant styles it.
TableFooterHTMLAttributes<HTMLTableSectionElement><tfoot>. Top border and tinted fill, both from the color token.
TableRowHTMLAttributes<HTMLTableRowElement><tr>. Draws nothing itself; the variant gives it borders and hover.
TableHeadThHTMLAttributes<HTMLTableCellElement><th>. A header cell — pass scope="col" or scope="row".
TableDataTdHTMLAttributes<HTMLTableCellElement><td>. A data cell — colSpan and rowSpan pass through.
TableCaptionHTMLAttributes<HTMLTableCaptionElement><caption>. Names the table for assistive tech.