Skip to Content
MavKitOne is in beta. @mav-labs-inc/mavkit-react is not public packages yet.

Table

A controlled, column/data-driven data table. Table owns sort, selection, and search-filtering state; TableHeader, TableBody, and TableFooter render from that shared state, so no manual <thead>/<tbody> markup or data-* wiring is needed.

Usage

import { Table, TableHeader, TableBody, TableFooter } from '@mav-labs-inc/mavkit-react' import type { TableColumn } from '@mav-labs-inc/mavkit-react' const columns: TableColumn<Order>[] = [ { key: 'id', header: 'Order' }, { key: 'total', header: 'Total', kind: 'numeric', cell: row => `$${row.total.toFixed(2)}` }, ] <Table columns={columns} data={orders} getRowId={o => o.id} onSelectionChange={setSelected}> <TableHeader /> <TableBody /> <TableFooter /> </Table>

Example

Click a column header to sort; check a row (or the header checkbox) to select.

ORD-1042Jamie Doepaid$128.50
ORD-1041Alex Kimpending$42.00
ORD-1040Sam Patelrefunded$76.25
ORD-1039Taylor Reedpaid$210.00

Props

Table

PropTypeDefaultDescription
columns*TableColumn<T>[]—
data*T[]—
getRowId*(row: T, index: number) => string—Stable unique id for a row — required for selection and React keys.
captionstring—
ariaLabelstring—
elevatedboolean—Adds a soft box shadow to lift the table above the page.
stripedboolean—
compactboolean—
borderedboolean—
cardMobileboolean—Collapses to a stacked-card layout at ≤639px.
selectablebooleantrueEnables the checkbox column and selection state.
rowClickToSelectbooleanfalseClicking anywhere on a row (outside interactive elements) toggles its selection.
selectedstring[]—Controlled selected row ids — pair with onSelectionChange.
defaultSelectedstring[][]
onSelectionChange(ids: string[]) => void—
sortablebooleantrueEnables column sort buttons.
sortTableSort | null—Controlled sort — { col: string; dir: 'asc' | 'desc' | 'none' }. Pair with onSortChange.
defaultSortTableSort | nullnull
onSortChange(sort: TableSort | null) => void—
searchQuerystring—Filters rows whose searchable text doesn't include this query (case-insensitive).
isRowDisabled(row: T) => boolean—
emptyStateReactNode—Shown in the body when there are no rows to display (after search filtering).
classNamestring—
childrenReactNode—TableHeader / TableBody render inside <table>; TableFooter renders after it.

TableColumn

PropTypeDefaultDescription
key*string—Unique key for this column. Used for sorting, searching, and as the React key.
header*ReactNode—
headerLabelstring—Accessible name for the sort button when header isn't plain text.
cell(row: T, rowIndex: number) => ReactNode—Defaults to String(row[key]) via accessor.
accessor(row: T) => string | number—Value used for sorting/searching. Defaults to row[key].
sortableboolean—Overrides the table-level sortable for this column.
kind'numeric' | 'actions'—Right-aligns + tabular numerals, or styles as a trailing actions column.
widthstring—
classNamestring—

TableFooter

With no children, shows a row-count / selection summary; pass children (e.g. a Paginator variant="table") to take over the content.

PropTypeDefaultDescription
classNamestring—
childrenReactNode—

useTable<T>()

Access the enclosing Table’s shared state — for building custom header/body/footer content. Throws if called outside a Table.

Last updated on