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 the component from its dedicated entry point to keep the dependency and generated bundle explicit.
tsximport { Table } from "@tavojs/ui/table";Normal Tavo.js applications load component styles through the Tavo.js UI plugin. If the application manages component CSS manually, also import @tavojs/ui/css/table.
When to use
Use it when
Choose something else when
Examples
Compound table
tsximport { Table } from "@tavojs/ui/table";
export function TableExample1() {
return (
<>
<Table.Root caption="Invoices"><Table.Head><Table.Row><Table.HeaderCell>Status</Table.HeaderCell></Table.Row></Table.Head><Table.Body><Table.Row><Table.Cell>Paid</Table.Cell></Table.Row></Table.Body></Table.Root>
</>
);
}Common props and defaults
| 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. |
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, 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 |