Web · Components
Table
Data table.
Live example
Preview
| Orders | Status | |||
|---|---|---|---|---|
| #1027 | Can Öztürk | Paid | Oct 9, 2026 | $980.00 |
| #1026 | Zeynep Demir | Paid | Oct 4, 2026 | $250.00 |
| #1025 | Mehmet Kaya | Pending | Oct 3, 2026 | $1,420.00 |
| #1024 | Ayşe Yılmaz | Paid | Oct 1, 2026 | $250.00 |
| Total | 2900 |
Code
Events
- Events appear here when you interact with the preview.
Import
Data table. Columns are given with columns, rows with rows; the header, cells, mobile card view, formatting and sorting come built in.
It is a server component: functions like render can be passed from the server too. Only the scrollbar part goes to the browser.
- Overflowing tables scroll horizontally in their own container; the page doesn't overflow.
- On phones each row turns into a card (
stackOnMobile), with the column name before each value. - With
format, numbers, currency, percentages and dates are formatted bylocale; numbers are right-aligned and line up withtabular-nums. - For sorting give
sort+onSortChange(in a client component). - For pagination give
pagination; if you give all rows the table slices the current page itself after sorting. In a server component pages become links withpagination={{ searchParams }}.
Examples
TableFormat
typeBuilt-in formats of a cell value. Numbers are formatted by locale.
TableColumn
interfaceColumn of Table.
| Name | Type | Description |
|---|---|---|
key | string | Id of the column; if value is omitted, the value of this field in the row is shown. |
header | ReactNode | Header cell. |
tooltip? | TooltipProp | Tooltip shown with an ⓘ icon next to the header (e.g. how the column is computed). See TooltipProp. |
mobileLabel? | string | Name written before the value in the mobile card view. If omitted and header is text, that is used. |
value? | (row: T) => unknown | Produces the cell value from the row (sorting and formatting use it too). |
render? | (row: T, index: number) => ReactNode | Fully customizes the cell content (e.g. a badge, a button). |
format? | TableFormat | Built-in format: number, currency, percent (0.25 → 25%), date. |
align? | "start" | "center" | "end" | Alignment. Numeric formats default to "end". |
sortable? | boolean | Clicking the header can sort by this column. See TableProps.sort. |
width? | string | Column width (CSS), e.g. "8rem" or "20%". |
hideOnMobile? | boolean | Hidden in the mobile card view. |
className? | string | Classes added to this column's cells. |
TableSort
interfaceSort state.
| Name | Type | Description |
|---|---|---|
key | string | key of the sorted column. |
direction | "asc" | "desc" | Direction. |
TableClassNames
interfaceClasses that can be passed to the inner parts of Table.
| Name | Type | Description |
|---|---|---|
container? | string | Scroll container. |
header? | string | Header row. |
row? | string | Each data row. |
footer? | string | Footer (totals) row. |
wrapper? | string | Container wrapping the table and pagination (when pagination is given). |
TablePagination
typeThe Table pagination prop: same as PaginationProps.
- If
total(orpageCount) is not given,rowscounts as all records; the table slices the current page itself after sorting. - If
totalis given,rowsis only the current page (server pagination).
Since the table is a server component it doesn't keep page state: give the page either with page + onPageChange (in a client component) or linked via searchParams (in a server component).
TableProps
interfaceProps of the Table component.
Extends: Omit<ComponentProps<"table">, "children">
| Name | Type | Default | Description |
|---|---|---|---|
columns | readonly TableColumn<T>[] | Columns. | |
rows | readonly T[] | Rows. | |
rowKey? | keyof T | ((row: T, index: number) => string | number) | Unique key of a row: a field name or a function. If omitted, the id field, otherwise the index is used. | |
caption? | ReactNode | Caption below the table; screen readers announce the table with it. | |
empty? | ReactNode | Content shown when there are no rows. Defaults to the tableEmpty text ("Kayıt yok"). | |
footer? | Partial<Record<string, ReactNode>> | Footer row content by column key (e.g. totals). | |
stackOnMobile? | boolean | true | On small screens (below 640 px) turns each row into a card; the column name is written before each value. If false the table scrolls horizontally. |
stickyHeader? | boolean | The header row stays fixed at the top on vertical scroll. Give a height (e.g. max-h-96) with classNames.container. | |
label? | string | Screen reader name of the scroll container; if given, it can be scrolled with the keyboard. | |
sort? | TableSort | null | Sorting. If given, rows are sorted by it and sortable column headers become clickable; you keep the state with onSortChange. | |
onSortChange? | (sort: TableSort | null) => void | Called with the new sort when a sortable header is clicked. | |
onRowClick? | (row: T, index: number) => void | Makes rows clickable (e.g. go to details). | |
selectedKey? | string | number | null | The row with this key looks selected. | |
locale? | string | Locale used for formatting. Defaults to the UIProvider's locale in a client tree, "tr-TR" on the server. | |
currency? | string | Currency. Defaults to the UIProvider's currency in a client tree, "TRY" on the server. | |
pagination? | TablePagination | Pagination below the table. See TablePagination. | |
classNames? | TableClassNames | Classes added to the inner parts. |