YuhuanStudioYunUIDocs
Data Display

Table

Semantic, presentational table family using design-system tokens.

A semantic, presentational table family built on design-system tokens. Table wraps a <table> in an overflow container so wide tables scroll instead of breaking layout. Compose it from TableHeader, TableBody, TableRow, TableHead and TableCell (short aliases Thead, Tbody, Tfoot, Tr, Th, Td are also exported).

Import

tsx
1import {
2 Table, TableHeader, TableBody, TableFooter,
3 TableRow, TableHead, TableCell, TableCaption,
4} from "@yuhuanowo/yunui";

Basic

Data table

ModelContextStatus
Claude Opus 4.8200KActive
DeepSeek R164KBeta
GPT-4o mini128KLimited

Summary row

ItemCost
Requests$42.00
Storage$8.40
Total$50.40
Billing for the current period.

Sortable columns

Pass onSort to a TableHead to make it a sort control: the label becomes a button with an asc/desc/unsorted chevron, and the <th> gets aria-sort. sortDirection is that column's current state ("asc" / "desc", or false when it isn't the active column). Sorting itself stays with you — YunUI only renders the control and the a11y state. Use align="right" for numeric columns; it aligns both the cells and the sort control.

Sortable

Model
Claude Opus 4.8200$15
GPT-4o mini128$1
DeepSeek R164$2

Props — Table

PropTypeDefaultDescription
containerClassNamestringClass applied to the outer scroll/overflow wrapper.
responsivebooleanStack each row into a labelled card below the `md` breakpoint, so dense many-column tables stay readable on narrow screens instead of forcing a horizontal scroll. Pair with `<TableCell label="…">` to label each value.
scrollLabelstringAccessible name for the scroll region, used only when the table is actually overflowing and therefore focusable (e.g. "Transactions, scrollable"). The library ships no copy, so without it the region is focusable but unnamed.

The sub-components forward the props of their underlying table elements (<thead>, <tbody>, <tr>, <th>, <td>) plus className:

PropTypeDefaultDescription
TableHeaderHTMLAttributes<HTMLTableSectionElement>Renders <thead>; column-header rows are divided by a subtle border.
TableBodyHTMLAttributes<HTMLTableSectionElement>Renders <tbody>; rows are divided by subtle borders.
TableFooterHTMLAttributes<HTMLTableSectionElement>Renders <tfoot>; a muted summary-row band.
TableRowHTMLAttributes<HTMLTableRowElement>Renders <tr> with a divider and hover highlight.
TableHeadThHTMLAttributes<HTMLTableCellElement>Column header cell <th>: left-aligned, uppercase, muted, small.
TableCellTdHTMLAttributes<HTMLTableCellElement>Standard data cell <td>.
TableCaptionHTMLAttributes<HTMLTableCaptionElement>Caption rendered below the table; muted helper text.

On this page