# Table _(no submodules)_ - table.variants — `tableVariants` and its eight sub-… - [table.variants](./table.variants.md) — `tableVariants` and its eight sub-component cva resolvers (`tableHeaderVariants`, `tableBodyVariants`, `tableFooterVari… - table.variants — `tableVariants` and its eight sub-… - [table.variants](./table.variants.md) — `tableVariants` and its eight sub-component cva resolvers (`tableHeaderVariants`, `tableBodyVariants`, `tableFooterVari… - table.variants — `tableVariants` and its eight sub-… - [table.variants](./table.variants.md) — `tableVariants` and its eight sub-component cva resolvers (`tableHeaderVariants`, `tableBodyVariants`, `tableFooterVari… - table.variants — `tableVariants` and its eight sub-… - [table.variants](./table.variants.md) — `tableVariants` and its eight sub-component cva resolvers (`tableHeaderVariants`, `tableBodyVariants`, `tableFooterVari… - [table.variants](./table.variants.md) — `tableVariants` and its eight sub-component cva resolvers (`tableHeaderVariants`, `tableBodyVariants`, `tableFooterVari… ## Purpose `` is the chassis pure-HTML table family — `
` (root, wrapping `
`), `` (``), `` (``), `` (``), `` (``), `` (`
`), `` (``), `` (`
`). The chassis exposes NO variants — typography and spacing are baked in so every chassis table renders consistently across consumers. The root wraps the native `` in an `overflow-auto` container so wide tables scroll horizontally without breaking the layout. For a headless data-table with sorting, pagination, and selection on top of these primitives, use ``. ## Features - Eight composition primitives mapping 1:1 to native HTML table elements. - `overflow-auto` wrapper on the root so wide tables scroll horizontally. - Logical-property text alignment (`text-start` on ``) so RTL renders correctly. - Hover + selected (`data-state="selected"`) row states on ``. - Footer reads as a summary surface (`bg-muted/50 font-medium`). - Caption sits below the table (`caption-bottom`) per conventional reading order. - All sub-components forward refs to their underlying native elements. ## Usage: Basic Example ```tsx import { Table, TableBody, TableCaption, TableCell, TableHead, TableHeader, TableRow, } from "@suaveplan/react-ui"; interface Invoice { readonly id: string; readonly status: string; readonly amount: string; } export function InvoiceTable({ invoices }: { invoices: Invoice[] }) { return (
A list of recent invoices. ID Status Amount {invoices.map((invoice) => ( {invoice.id} {invoice.status} {invoice.amount} ))}
); } ``` ## Usage: Advanced Example ```tsx import { Table, TableBody, TableCell, TableFooter, TableHead, TableHeader, TableRow, } from "@suaveplan/react-ui"; export function OrderTotals({ orders, grandTotal, }: { orders: Array<{ id: string; line: string; amount: number }>; grandTotal: number; }) { return ( Order Line Amount {orders.map((order) => ( {order.id} {order.line} ${order.amount.toFixed(2)} ))} Total ${grandTotal.toFixed(2)}
); } ``` ## API Reference ### `` `forwardRef` — root `
` wrapped in `
`. ### ``, ``, `` `forwardRef` — `
`, ``, `` row groups. ### `` `forwardRef` — ``. Hover + `data-state="selected"` background. ### `` `forwardRef` — `
` header cell. ### `` `forwardRef` — `` body cell. ### `` `forwardRef` — `
` rendered below the table. #### Errors The Table components do NOT call `useTranslation()` so they do not interact with the i18n provider. Children carrying user-perceivable text must be resolved at the call site. ## Implementation Notes - The chassis intentionally exposes NO `variant` axis on any sub-component — tables are pure-data surfaces and every chassis table should look the same. Consumers wanting different surfaces (zebra striping, dense layouts) override at the call site via `className` or register `variantOverrides` on their theme plugin. - The root wraps the native `` in `
` so wide tables scroll horizontally without breaking the page layout. This means refs forwarded to `
` reach the inner `
`, NOT the outer `
`. - `` always renders below the table thanks to `caption-bottom` on the root. Always include a caption (visually-hidden via `className="sr-only"` is acceptable) so screen-readers announce the table's purpose; tables without captions are unintelligible to screen-reader users. - `text-start` on `` uses Tailwind's logical-property class so the alignment flips automatically in RTL layouts. The same applies to `text-end` for right-aligned numeric columns — never use `text-left` / `text-right` in chassis-rendered tables. - The chassis does NOT inject any data-cell-binding behaviour. For a headless data-table with sorting, pagination, and selection on top of these primitives, use `` (which renders into the same `
` family).