Table
Present data in rows and columns with tables. Compare striped, compact, scrollable, and sticky layouts.
Examples
Default
Mobile
320pxMobile Lg
480pxTablet
640pxDesktop
1024px| Document title | Description | Year |
|---|---|---|
| Declaration of Independence | Statement declaring independence from the British Empire. | 1776 |
| Bill of Rights | The first ten amendments of the U.S. Constitution. | 1791 |
| Declaration of Sentiments | A declaration of the rights of American women. | 1848 |
| Emancipation Proclamation | An executive order granting freedom to enslaved people in designated states. | 1863 |
Striped
Mobile
320pxMobile Lg
480pxTablet
640pxDesktop
1024px| Document title | Description | Year |
|---|---|---|
| Declaration of Independence | Statement declaring independence from the British Empire. | 1776 |
| Bill of Rights | The first ten amendments of the U.S. Constitution. | 1791 |
| Declaration of Sentiments | A declaration of the rights of American women. | 1848 |
| Emancipation Proclamation | An executive order granting freedom to enslaved people in designated states. | 1863 |
Borderless
Mobile
320pxMobile Lg
480pxTablet
640pxDesktop
1024px| Document title | Description | Year |
|---|---|---|
| Declaration of Independence | Statement declaring independence from the British Empire. | 1776 |
| Bill of Rights | The first ten amendments of the U.S. Constitution. | 1791 |
| Declaration of Sentiments | A declaration of the rights of American women. | 1848 |
| Emancipation Proclamation | An executive order granting freedom to enslaved people in designated states. | 1863 |
Compact
Mobile
320pxMobile Lg
480pxTablet
640pxDesktop
1024px| Document title | Description | Year |
|---|---|---|
| Declaration of Independence | Statement declaring independence from the British Empire. | 1776 |
| Bill of Rights | The first ten amendments of the U.S. Constitution. | 1791 |
| Declaration of Sentiments | A declaration of the rights of American women. | 1848 |
| Emancipation Proclamation | An executive order granting freedom to enslaved people in designated states. | 1863 |
Scrollable
Mobile
320pxMobile Lg
480pxTablet
640pxDesktop
1024px| Document title | Description | Year |
|---|---|---|
| Declaration of Independence | Statement declaring independence from the British Empire. | 1776 |
| Bill of Rights | The first ten amendments of the U.S. Constitution. | 1791 |
| Declaration of Sentiments | A declaration of the rights of American women. | 1848 |
| Emancipation Proclamation | An executive order granting freedom to enslaved people in designated states. | 1863 |
Sticky Header
Mobile
320pxMobile Lg
480pxTablet
640pxDesktop
1024px| Document title | Description | Year |
|---|---|---|
| Declaration of Independence | Statement declaring independence from the British Empire. | 1776 |
| Bill of Rights | The first ten amendments of the U.S. Constitution. | 1791 |
| Declaration of Sentiments | A declaration of the rights of American women. | 1848 |
| Emancipation Proclamation | An executive order granting freedom to enslaved people in designated states. | 1863 |
| Declaration of Independence | Statement declaring independence from the British Empire. | 1776 |
| Bill of Rights | The first ten amendments of the U.S. Constitution. | 1791 |
| Declaration of Sentiments | A declaration of the rights of American women. | 1848 |
| Emancipation Proclamation | An executive order granting freedom to enslaved people in designated states. | 1863 |
Sticky Column
Mobile
320pxMobile Lg
480pxTablet
640pxDesktop
1024px| Document title | Description | Year |
|---|---|---|
| Declaration of Independence | Statement declaring independence from the British Empire. | 1776 |
| Bill of Rights | The first ten amendments of the U.S. Constitution. | 1791 |
| Declaration of Sentiments | A declaration of the rights of American women. | 1848 |
| Emancipation Proclamation | An executive order granting freedom to enslaved people in designated states. | 1863 |
Stacked
Mobile
320pxMobile Lg
480pxTablet
640pxDesktop
1024px| Document title | Description | Year |
|---|---|---|
| Declaration of Independence | Statement declaring independence from the British Empire. | 1776 |
| Bill of Rights | The first ten amendments of the U.S. Constitution. | 1791 |
| Declaration of Sentiments | A declaration of the rights of American women. | 1848 |
| Emancipation Proclamation | An executive order granting freedom to enslaved people in designated states. | 1863 |
On narrow screens, stacked hides the visual header row and places each cell on its own line. Keep the native caption and column headers, and add a data-label that matches its column heading to every body cell.
Sortable
Mobile
320pxMobile Lg
480pxTablet
640pxDesktop
1024px| National Park Service | 20,248 | Jun 12, 2025 |
|---|---|---|
| Census Bureau | 10,632 | Mar 28, 2025 |
| National Archives | 2,915 | Aug 4, 2025 |
| Smithsonian Institution | 6,547 | Jan 17, 2025 |
Install @tanstack/react-table to sort the data. Table.Root supplies sort buttons, aria-sort, and a status announcement; onSortChange forwards the requested column and direction to TanStack Table, whose row model supplies the reordered rows. Keep the Table sort state and row order in sync so the announcement describes the visible data.
Component API
Compose native table parts inside Root. Use column indices for machine-driven sorting and stacked cell labels.
Root<table>
Renders a div around the native table and an automatic sort status region. Native table props apply to the inner table.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | bordered | striped | borderless | bordered | Selects border and row styling. |
compact | boolean | false | Reduces cell padding. |
stacked | boolean | false | Stacks cells on narrow screens. |
captionText | string | — | Caption text for table sorting status. |
columnNames | Record<number, string> | — | Accessible names for column indices. Every sortable ColumnHeader requires a nonempty matching entry. |
defaultSortDescriptor | { column: number; direction: 'ascending' | 'descending' } | null | — | Initial uncontrolled sort state. |
sortDescriptor | { column: number; direction: 'ascending' | 'descending' } | null | — | Controlled sort state. Use null for an unsorted table and reorder your rows to match. |
onSortChange | ({ sortDescriptor: SortDescriptor | null }) => void | — | Receives sorting requests. Update sortDescriptor and the row order together. |
Caption<caption>
Names the table.
Header<thead>
Contains column headings.
| Prop | Type | Description |
|---|---|---|
sticky | boolean | Keeps the header visible while scrolling. |
Body<tbody>
Contains data rows.
Footer<tfoot>
Contains footer rows.
Row<tr>
Contains cells.
ColumnHeader<th>
Labels a column.
| Prop | Type | Description |
|---|---|---|
columnIndex | number | Connects this heading to the sorting machine. |
sortable | boolean | Renders a sort button when columnIndex is supplied. |
| Attribute | Value | Purpose |
|---|---|---|
data-sortable | Present when sortable | Style sortable column headings. |
Cell<td>
Displays one value. Supply data-label for a stacked cell heading.
| Prop | Type | Description |
|---|---|---|
columnIndex | number | Connects this cell to the active sorted column. |
| Attribute | Value | Purpose |
|---|---|---|
data-sort-active | Present for cells in the sorted column | Styles the active sorted column. |
ScrollArea<div>
Wraps the table in a horizontally scrollable region.
SrStatus<div>
Announces sort changes. Root renders this part automatically; do not add a second status region.
Accessibility
Provide a caption and column headings. Handle onSortChange in the data source so sorted rows match the announced sort state.