DataTable

Tabular data with sortable columns, custom cell renderers, and built-in pagination. Pure React — no headless library wrapped.

NameRoleStatusJoined
CrisLead designeractive2024-01-15
AnyaFrontendactive2024-02-08
MikeBackendinvited2024-04-22
SaraProductactive2024-05-30
Page 1 of 2

Usage

import { DataTable, type DataTableColumn } from '@bwo-ui/react';

const columns: DataTableColumn<Row>[] = [
  { id: 'name', header: 'Name', accessor: (r) => r.name, sortable: true },
  { id: 'role', header: 'Role', accessor: (r) => r.role, sortable: true },
  { id: 'joined', header: 'Joined', accessor: (r) => r.joined, align: 'right' },
];

<DataTable data={rows} columns={columns} pageSize={10} hoverable />

Props

PropTypeDefaultDescription
dataT[]Row data.
columnsDataTableColumn<T>[]Column definitions.
getRowId(row, index) => stringStable row key. Default: index.
sort{ id, direction } | nullControlled sort state.
onSortChange(sort) => voidSort change handler.
pageSizenumberWhen set, paginates rows.
pagenumberControlled current page (1-based).
stripedbooleanAlternating row backgrounds.
hoverablebooleanHighlight rows on hover.
onRowClick(row, i) => voidOptional click handler per row.