Table
Rows and columns of data, with sortable headers, stripes and sideways scrolling.Invoice
Status
Amount
INV-001
Paid
$250.00
INV-002
Pending
$150.00
INV-003
Unpaid
$350.00
JSX
<Table caption="Recent invoices">
<Table.Header>
<Table.Row>
<Table.Head>Invoice</Table.Head>
<Table.Head>Status</Table.Head>
<Table.Head align="end">Amount</Table.Head>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>INV-001</Table.Cell>
<Table.Cell>Paid</Table.Cell>
<Table.Cell align="end">$250.00</Table.Cell>
</Table.Row>
…
</Table.Body>
</Table>Installation
Package
CLI (copy source)
pnpm
pnpm add @advui/datanpm
npm install @advui/dataUsage
import { Table } from '@advui/data'
<Table caption="Recent invoices">
<Table.Header>
<Table.Row>
<Table.Head>Invoice</Table.Head>
<Table.Head align="end">Amount</Table.Head>
</Table.Row>
</Table.Header>
<Table.Body>
<Table.Row>
<Table.Cell>INV-001</Table.Cell>
<Table.Cell align="end">$250.00</Table.Cell>
</Table.Row>
</Table.Body>
</Table>Examples
Basic
A wider partner column and a totals footer.Preview
Code
Recent invoices
Sortable columns
Your code sorts the rows; the header shows and announces the direction.Preview
Code
Region
Hlaing Tharyar
Yangon
687,867
Mawlamyine
Mon
289,388
Pyigyitagon
Mandalay
237,618
Sittwe
Rakhine
147,899
Striped, scrolling sideways
Preview
Code
Coverage by sector. Scroll sideways on small screens.
API reference
Table
| Prop | Type | Default | Description |
|---|---|---|---|
caption | ReactNode | — | Names the table (`aria-labelledby`); shown under it. Or pass `aria-label`. |
variant | 'plain' | 'outline' | 'plain' | `outline` puts the table on a bordered card surface. |
size | 'sm' | 'md' | 'md' | Cell padding: compact or comfortable. |
striped | boolean | false | Shades every other body row. |
minWidth | number | — | Below this width the table scrolls sideways instead of squeezing columns. |
Table.Header
The row group of column headers.Table.Body
The row group of data rows, divided (and striped with `striped`).Table.Footer
A shaded row group, for totals.Table.Row
| Prop | Type | Default | Description |
|---|---|---|---|
selected | boolean | false | Highlights the row. |
Table.Head
| Prop | Type | Default | Description |
|---|---|---|---|
align | 'start' | 'center' | 'end' | 'start' | Match the column’s cells. |
sortDirection | 'ascending' | 'descending' | 'none' | — | Makes the header a sort button and sets `aria-sort`. |
onSort | () => void | — | Called when the header is pressed. |
Table.Cell
Plain text is wrapped in body text. Set `width` or `flex` on the cells and header of a column to size it.| Prop | Type | Default | Description |
|---|---|---|---|
align | 'start' | 'center' | 'end' | 'start' | Use `end` for numbers. |
Accessibility
- Uses the ARIA table roles (
table,rowgroup,row,columnheader,cell), so screen readers can move by row and column and read each cell with its header. - Name every table with
captionoraria-label. - A sortable header holds a button and sets
aria-sort; the icon is hidden. On native, where there is noaria-sort, the button’s name says how the column is sorted. - With
minWidth, the scrolling area can take focus on web, so the arrow keys scroll it.
| Key | Action |
|---|---|
| Tab | Moves to the sort buttons and any controls in cells. |
| Enter / Space | Sorts by the focused header. |
| Arrow keys | Scroll a focused table that is wider than the screen. |
Responsive behavior
Columns share the width equally unless cells set width or flex. Set minWidth so a wide table scrolls sideways on phones.
Platform notes
Web
Built from flex rows with ARIA table roles rather than
<table>, so the layout is the same on every platform.iOS
VoiceOver reads cells in row order.
Android
Same as iOS.