Table
Accessible table primitives with caption, head, rows, and cells.
Preview
A live, theme-aware example rendered with the published component.
Loading preview…
Import
Import from the focused entry point below, or use the same named export from @tavojs/ui. Both are public APIs; measure the built application when comparing their bundle cost.
tsximport { Table } from "@tavojs/ui/table";The component import loads compiled component CSS. Enable tavoUi() for your project theme variables, or import @tavojs/ui/theme.css once for the package default theme. The equivalent CSS-safe component alias is @tavojs/ui/css/table.
When to use
Use it when
Choose something else when
Examples
These examples include imports and local state where interaction requires it. Render the exported component in a page after completing UI installation. Demo state stays in the mounted component; connect file handling, persistence, and data loading to your application as needed.
Compound table
tsximport { Table } from "@tavojs/ui/table";
export function TableExample1() {
return (
<>
<Table.Root>
<Table.Caption>Invoices</Table.Caption>
<Table.Head><Table.Row><Table.HeaderCell scope="col">Invoice</Table.HeaderCell><Table.HeaderCell scope="col">Status</Table.HeaderCell></Table.Row></Table.Head>
<Table.Body><Table.Row><Table.Cell>INV-001</Table.Cell><Table.Cell>Paid</Table.Cell></Table.Row></Table.Body>
</Table.Root>
</>
);
}Common props and defaults
A curated starting point. The complete TypeScript API below includes additional props and compound member contracts.
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Optional class hook applied to the public root element owned by the component. |
compact | boolean | false | Uses denser row spacing when supported. |
TableCell.numeric | boolean | — | Configures TableCell.numeric for this component. |
TableHeaderCell.numeric | boolean | — | Configures TableHeaderCell.numeric for this component. |
caption | Child | — | Accessible table caption when supported. |
columns | TableDataColumn[] | — | Column definitions for Table.Data. |
rows | Record<string, unknown>[] | — | Rows for Table.Data. |
Complete TypeScript API
Import from @tavojs/ui/table. Published exports: Table, TableBody, TableCaption, TableCell, TableCellProps, TableData, TableDataColumn, TableDataProps, TableHead, TableHeaderCell, TableProps, TableRoot, TableRow.
TableProps
| Property | Type | Required | Description |
|---|---|---|---|
children | Child | No | Inherited children attribute accepted by Table. |
className | string | No | Optional class hook applied to the public root element owned by the component. |
sx | Sx | No | Inherited sx attribute accepted by Table. |
id | string | No | Inherited id attribute accepted by Table. |
role | string | No | Inherited role attribute accepted by Table. |
style | Record<string, unknown> | No | Inherited style attribute accepted by Table. |
title | string | No | Inherited title attribute accepted by Table. |
tabIndex | number | No | Inherited tabIndex attribute accepted by Table. |
hidden | boolean | No | Inherited hidden attribute accepted by Table. |
disabled | boolean | No | Inherited disabled attribute accepted by Table. |
onClick | TavoEventHandler<MouseEvent> | No | Inherited onClick attribute accepted by Table. |
onChange | TavoEventHandler<Event> | No | Inherited onChange attribute accepted by Table. |
onInput | TavoEventHandler<Event> | No | Inherited onInput attribute accepted by Table. |
onKeyDown | TavoEventHandler<KeyboardEvent> | No | Inherited onKeyDown attribute accepted by Table. |
onFocus | TavoEventHandler<FocusEvent> | No | Inherited onFocus attribute accepted by Table. |
onBlur | TavoEventHandler<FocusEvent> | No | Inherited onBlur attribute accepted by Table. |
compact | boolean | No | Uses denser row spacing when supported. |
TableCellProps
| Property | Type | Required | Description |
|---|---|---|---|
children | Child | No | Inherited children attribute accepted by Table. |
className | string | No | Optional class hook applied to the public root element owned by the component. |
sx | Sx | No | Inherited sx attribute accepted by Table. |
id | string | No | Inherited id attribute accepted by Table. |
role | string | No | Inherited role attribute accepted by Table. |
style | Record<string, unknown> | No | Inherited style attribute accepted by Table. |
title | string | No | Inherited title attribute accepted by Table. |
tabIndex | number | No | Inherited tabIndex attribute accepted by Table. |
hidden | boolean | No | Inherited hidden attribute accepted by Table. |
disabled | boolean | No | Inherited disabled attribute accepted by Table. |
onClick | TavoEventHandler<MouseEvent> | No | Inherited onClick attribute accepted by Table. |
onChange | TavoEventHandler<Event> | No | Inherited onChange attribute accepted by Table. |
onInput | TavoEventHandler<Event> | No | Inherited onInput attribute accepted by Table. |
onKeyDown | TavoEventHandler<KeyboardEvent> | No | Inherited onKeyDown attribute accepted by Table. |
onFocus | TavoEventHandler<FocusEvent> | No | Inherited onFocus attribute accepted by Table. |
onBlur | TavoEventHandler<FocusEvent> | No | Inherited onBlur attribute accepted by Table. |
numeric | boolean | No | Inherited numeric attribute accepted by Table. |
TableDataProps
| Property | Type | Required | Description |
|---|---|---|---|
children | Child | No | Inherited children attribute accepted by Table. |
className | string | No | Optional class hook applied to the public root element owned by the component. |
sx | Sx | No | Inherited sx attribute accepted by Table. |
id | string | No | Inherited id attribute accepted by Table. |
role | string | No | Inherited role attribute accepted by Table. |
style | Record<string, unknown> | No | Inherited style attribute accepted by Table. |
title | string | No | Inherited title attribute accepted by Table. |
tabIndex | number | No | Inherited tabIndex attribute accepted by Table. |
hidden | boolean | No | Inherited hidden attribute accepted by Table. |
disabled | boolean | No | Inherited disabled attribute accepted by Table. |
onClick | TavoEventHandler<MouseEvent> | No | Inherited onClick attribute accepted by Table. |
onChange | TavoEventHandler<Event> | No | Inherited onChange attribute accepted by Table. |
onInput | TavoEventHandler<Event> | No | Inherited onInput attribute accepted by Table. |
onKeyDown | TavoEventHandler<KeyboardEvent> | No | Inherited onKeyDown attribute accepted by Table. |
onFocus | TavoEventHandler<FocusEvent> | No | Inherited onFocus attribute accepted by Table. |
onBlur | TavoEventHandler<FocusEvent> | No | Inherited onBlur attribute accepted by Table. |
columns | TableDataColumn<TRow>[] | Yes | Column definitions for Table.Data. |
rows | TRow[] | Yes | Rows for Table.Data. |
compact | boolean | No | Uses denser row spacing when supported. |
State ownership and DOM target
| Concern | Contract |
|---|---|
| State | No component state contract is exposed; the application owns the rendered content and surrounding behavior. |
| DOM target | Public passthrough props target the component root. Treat nested elements and private class names as implementation details. |
Anatomy and related components
Public compound members: Root, Caption, Head, Body, Row, HeaderCell, Cell, Data
Limitations
Avoid for purely visual grids; use Grid or Stack instead.
Use only the documented props, entry points, and compound members. Internal DOM nesting and CSS class names can change without becoming part of the public component contract.
Accessibility
Data components should preserve readable order and expose labels for non-textual values.
Use captions or nearby headings for tables and charts.
Do not rely on color alone for status.
Keep values and labels available as text.
Component status
| Contract | Current value |
|---|---|
| Maturity | stable |
| Category | data |
| Component import | @tavojs/ui/table |
| Explicit CSS import | @tavojs/ui/css/table |
| Preview | Interactive preview available on this page |