Table
A responsive table. Columns are fixed or weighted; when the table is narrower than its columns' minimum widths, every row becomes a card of "Head: value" lines (adaptive: 'auto').
Usage
Approximate web preview — the HarmonyOS rendering is the reference.
Data form
Pass rows: string[][] (and footer) instead of slots. adaptive: 'table' keeps the table and scrolls horizontally when it does not fit.
Approximate web preview — the HarmonyOS rendering is the reference.
Large data
The data form is virtualized (List + Repeat.virtualScroll()): only the rows in view exist and scrolled-out rows are reused, so 10 000 rows open and scroll like 10. Narrow the frame to see the virtualized card layout.
Approximate web preview — the HarmonyOS rendering is the reference.
BIG_ROWS.length rows · frame = full
API
Extracted from the @Param / @Event / @BuilderParam declarations in the library sources.
STable
shadcn-vue Table (w-full caption-bottom text-sm), with column sizing and a responsive card layout.
Slot form:
Data form (no slots): STable({ columns: this.cols, rows: [['INV001', '$250.00'], ...], footer: [...] }). The data form is virtualized (List + Repeat.virtualScroll(), ADR D14): 10 000 rows render as fast as 10. Its body scrolls inside the table once it is taller than bodyHeight (default 480vp above 50 rows), with the header kept in view. Use the data form for long tables; the slot form builds every row.
Columns (STableColumn): ArkUI cannot size arbitrary children, so the table owns the widths — fixed vp or a weight of the remaining width with a min width — and each cell reads the width of its index (its position in the row; pass column to override). When the columns do not fit, the table scrolls horizontally (adaptive: 'table') or — with adaptive: 'auto' (default) — turns every row into a card of "Head: value" lines. 'cards' always shows cards.
| Prop | Type | Default | Description |
|---|---|---|---|
columns | STableColumn[] | [] | |
adaptive | TableAdaptiveTableAdaptive = 'auto' | 'table' | 'cards' | 'auto' | |
rows | string[][] | undefined | undefined | Data form: one string per column for each row. Leave undefined to use the slot. |
footer | string[] | undefined | undefined | Data form: optional footer cells. |
bodyHeight | number | undefined | undefined | Data form: body viewport height (vp). Rows beyond it scroll inside the table and are built lazily. Unset: the body follows its rows up to 50 rows, above that it gets a 480vp viewport (ADR D14). |
rowKey | ((row: string[], index: number) => string) | undefined | undefined | Data form: stable row key (default: the row index). Give one when rows are inserted / reordered. |
caption | ResourceStr | undefined | undefined | Caption below the table (text-muted-foreground mt-4 text-sm). |
Slots: children (trailing closure)
STableCaption
Table caption (text-muted-foreground mt-4 text-sm, centred). Write it after the body.
| Prop | Type | Default | Description |
|---|---|---|---|
text | ResourceStr | '' |
STableHeader
<thead>: its rows always draw a bottom border. Hidden in the card layout.
Slots: children (trailing closure)
STableBody
<tbody>: the last row has no bottom border.
Slots: children (trailing closure)
STableFooter
<tfoot>: bg-muted/50 border-t font-medium.
Slots: children (trailing closure)
STableRow
<tr>: border-b transition-colors hover:bg-muted/50, bg-muted when selected. In the card layout it is a bordered card listing "Head: value" lines.
| Prop | Type | Default | Description |
|---|---|---|---|
selected | boolean | false |
Slots: children (trailing closure)
STableHead
<th>: h-10 px-2 text-left font-medium text-muted-foreground whitespace-nowrap. Width / alignment come from its column (its position in the row, or column).
| Prop | Type | Default | Description |
|---|---|---|---|
text | ResourceStr | undefined | undefined | |
column | number | undefined | undefined | Column index; defaults to the position in the row. |
Slots: children (trailing closure)
STableCell
<td>: p-2 align-middle whitespace-nowrap. Pass text or slot content (badges, buttons …). Width / alignment come from its column (its position in the row, or column).
| Prop | Type | Default | Description |
|---|---|---|---|
text | ResourceStr | undefined | undefined | |
column | number | undefined | undefined | Column index; defaults to the position in the row. |
Slots: children (trailing closure)