DataTable
Pass columns and data. DataTable uses TanStack table-core for row models and
renders semantic table markup.
import { DataTable } from '@manti-ui/react'; import type { DataTableColumn } from '@manti-ui/react'; interface Member { name: string; role: string; location: string; } const data: Member[] = [ { name: 'Ada Lovelace', role: 'Engineer', location: 'London' }, { name: 'Alan Turing', role: 'Researcher', location: 'Manchester' }, { name: 'Grace Hopper', role: 'Architect', location: 'New York' }, ]; const columns: DataTableColumn<Member>[] = [ { accessorKey: 'name', header: 'Name' }, { accessorKey: 'role', header: 'Role' }, { accessorKey: 'location', header: 'Location' }, ]; export default function DataTableBasic() { return <DataTable columns={columns} data={data} />; }
Columns and sorting
Columns use the re-exported DataTableColumn<TData> type. Use accessorKey for
plain values, cell for custom rendering, and meta.align for alignment.
Set sortable to add accessible sort buttons.
| INV-001 | Acme Corp | paid | $1,200.00 |
| INV-002 | Globex | pending | $450.50 |
| INV-003 | Initech | overdue | $3,120.00 |
| INV-004 | Umbrella | paid | $88.00 |
Entity stores and row props
Use getRowProps, getCellProps, and getRowId for native, ARIA, and data
attributes. When each row must resolve a live entity reference with hooks, pass
rowComponent. It is a real React component boundary, unlike a render callback,
so hooks remain valid. Spread rowProps onto its semantic <tr> and render
children for the generated cells.
Filtering, pagination, and selection
Enable filterable, paginated, or selectable independently or together.
Invoices
| INV-001 | Acme Corp | paid | $1,200.00 | |
| INV-002 | Globex | pending | $450.50 | |
| INV-003 | Initech | overdue | $3,120.00 | |
| INV-004 | Umbrella | paid | $88.00 | |
| INV-005 | Soylent | pending | $640.00 |
0 selected
Sizes
| Name | Role | Location |
|---|---|---|
| Ada Lovelace | Engineer | London |
| Alan Turing | Researcher | Manchester |
| Grace Hopper | Architect | New York |
| Name | Role | Location |
|---|---|---|
| Ada Lovelace | Engineer | London |
| Alan Turing | Researcher | Manchester |
| Grace Hopper | Architect | New York |
| Name | Role | Location |
|---|---|---|
| Ada Lovelace | Engineer | London |
| Alan Turing | Researcher | Manchester |
| Grace Hopper | Architect | New York |
API
| Prop | Type | Default | Description |
|---|---|---|---|
columns | DataTableColumn<TData>[] | — | Column definitions (TanStack `ColumnDef`). Set `meta.align` to align a column. |
data | TData[] | — | The rows to render. |
title | ReactNode | — | A heading shown at the start of the toolbar; also names the table. |
sortable | boolean | false | Enable click-to-sort headers (one column at a time). |
filterable | boolean | false | Add a global search box that filters across every column. |
filterPlaceholder | string | 'Search…' | Placeholder for the search box. |
paginated | boolean | false | Paginate client-side, with a Pagination control in the footer. |
pageSize | number | 10 | Rows per page when `paginated`. |
selectable | boolean | false | Add a leading checkbox column for row selection. |
onSelectionChange | (rows: TData[]) => void | — | Called with the selected rows whenever the selection changes. |
size | 'sm' | 'md' | 'lg' | 'md' | Row density. |
stickyHeader | boolean | false | Pin the header while the body scrolls (needs a bounded height). |
zebra | boolean | false | Tint alternating rows. |
interactive | boolean | false | Highlight rows on hover. |
caption | ReactNode | — | Optional caption rendered above the grid. |
emptyContent | ReactNode | 'No data' | Shown in place of rows when `data` is empty. |
getRowId | (row: TData, index: number) => string | — | Derive a stable row id (defaults to the row index). |
getRowProps | (row: TData, index: number) => HTMLAttributes<HTMLTableRowElement> | — | Add native, ARIA, and data props to each row. |
getCellProps | (row: TData, columnId: string, index: number) => TdHTMLAttributes | — | Add native, ARIA, and data props to each cell. |
rowComponent | ComponentType<DataTableRowComponentProps<TData>> | — | A hook-safe component boundary for resolving live/normalized row entities. |
Styling
Anatomy
| Part | Selector | Description |
|---|---|---|
root | [data-scope="data-table"][data-part="root"] | The panel framing the toolbar, grid, and footer. |
toolbar | [data-scope="data-table"][data-part="toolbar"] | The top bar holding the title and search box. |
title | [data-scope="data-table"][data-part="title"] | The toolbar heading (when `title` is set). |
search | [data-scope="data-table"][data-part="search"] | The search field wrapper. |
viewport | [data-scope="data-table"][data-part="viewport"] | The scrollable region wrapping the table. |
table | [data-scope="data-table"][data-part="table"] | The <table> element. |
caption | [data-scope="data-table"][data-part="caption"] | The <caption>, when provided. |
header | [data-scope="data-table"][data-part="header"] | The <thead>. |
header-row | [data-scope="data-table"][data-part="header-row"] | A header <tr>. |
header-cell | [data-scope="data-table"][data-part="header-cell"] | A header <th>; carries `aria-sort` and `data-align`. |
sort-trigger | [data-scope="data-table"][data-part="sort-trigger"] | The header button toggling sort (sortable columns). |
sort-indicator | [data-scope="data-table"][data-part="sort-indicator"] | The arrow reflecting sort direction. |
body | [data-scope="data-table"][data-part="body"] | The <tbody>. |
row | [data-scope="data-table"][data-part="row"] | A body <tr>; carries `data-selected` when selected. |
cell | [data-scope="data-table"][data-part="cell"] | A body <td>; carries `data-align`. |
empty | [data-scope="data-table"][data-part="empty"] | The cell shown when there are no rows. |
footer | [data-scope="data-table"][data-part="footer"] | The bottom bar holding the selection summary and pager. |
selection-summary | [data-scope="data-table"][data-part="selection-summary"] | The “N selected” count (when selectable). |
Tokens
| Token | Controls |
|---|---|
--manti-data-table-radius | radius |
--manti-data-table-cell-padding-x | cell padding x |
--manti-data-table-cell-padding-y | cell padding y |
--manti-data-table-font-size | font size |
--manti-data-table-header-font-size | header font size |
Last updated