Components

Table

Semantic HTML table with styled header, body, and rows for displaying structured data.

Category: Data Display / Composite

Import

import {
  Table,
  TableHeader,
  TableBody,
  TableRow,
  TableHead,
  TableCell,
} from "@hareru/ui"

Exports

NameHTML ElementBEM ClassDescription
Table<table>hui-tableRoot table (wrapped in hui-table__wrapper for horizontal scroll)
TableHeader<thead>hui-table__headerTable header section
TableBody<tbody>hui-table__bodyTable body section
TableRow<tr>hui-table__rowTable row
TableHead<th>hui-table__headHeader cell
TableCell<td>hui-table__cellBody cell
TableHeadPropsTypeProps for TableHead
TableCellPropsTypeProps for TableCell

Key Props

TableHead / TableCell

PropTypeDefaultDescription
align"left" | "center" | "right"Text alignment (adds BEM modifier class)

Structure

  • TableHeader [container]
  • TableBody [container] (expected)
    • TableRow [item] (expected) ×N
      • TableHead [label] ×N
      • TableCell [content] ×N

(expected) = recommended in canonical composition, not runtime-required.

  • TableRow is also valid inside TableHeader.

Accessibility

  • Notes: Uses semantic HTML table elements (table, thead, tbody, tfoot, tr, th, td).

Usage

import {
  Table,
  TableHeader,
  TableBody,
  TableRow,
  TableHead,
  TableCell,
  Badge,
} from "@hareru/ui"

<Table>
  <TableHeader>
    <TableRow>
      <TableHead>Name</TableHead>
      <TableHead>Status</TableHead>
      <TableHead align="right">Amount</TableHead>
    </TableRow>
  </TableHeader>
  <TableBody>
    <TableRow>
      <TableCell>Invoice #001</TableCell>
      <TableCell><Badge variant="secondary">Pending</Badge></TableCell>
      <TableCell align="right">$1,200.00</TableCell>
    </TableRow>
    <TableRow>
      <TableCell>Invoice #002</TableCell>
      <TableCell><Badge>Paid</Badge></TableCell>
      <TableCell align="right">$800.00</TableCell>
    </TableRow>
  </TableBody>
</Table>

Notes

  • Table is wrapped in a hui-table__wrapper div for horizontal scrolling on narrow viewports.
  • Uses semantic HTML table elements — no custom accessibility roles needed.
  • Compose Badge inside cells for status columns and Button for row-level actions.

On this page