bmates-uiBMates UI
Latest
/Components

DataTable

A table with client-side sorting, filtering, and row selection.

A table with client-side sorting, filtering, and row selection.

Import

import { DataTable } from 'bmates-ui';

Basic usage

The example below mirrors the primary Storybook composition and can be used as a starting point.

<DataTable
  columns={[
    { id: 'name', header: 'Name', accessor: row => row.name, sortable: true },
    { id: 'role', header: 'Role', accessor: row => row.role },
  ]}
  data={[
    { id: 'jane', name: 'Jane Doe', role: 'Designer' },
    { id: 'sam', name: 'Sam Lee', role: 'Engineer' },
  ]}
  getRowId={row => row.id}
  filterable
/>

Preview

DataTable

Prop previews

The examples below isolate the props that change visual output or interaction.

Filtering

Filtering

Row selection

Row selection

Empty state

Empty state

Component API

columns

Required columns with id, header, and optional accessor, cell, or sortable.

data

Required row data.

getRowId

Required stable row identifier.

selectable

Shows row-selection controls.

filterable

Shows the client-side filter field.

filterPlaceholder

Filter input placeholder.

emptyMessage

Content shown when no rows match.

selectedRowIds

Controlled selection state.

onSelectedRowIdsChange

Receives selection changes.

defaultSelectedRowIds

Initially selected row IDs in uncontrolled mode.

className

Additional class name for the root element.

Usage notes

  • Every component in the table is exported from bmates-ui.
  • Unless noted otherwise, a component also accepts the standard props of its underlying HTML element.
  • For application-owned state, use a controlled value and its change handler instead of only a default* prop.