Data Table

The Data Table component allows for easy display of tabular data with options for sorting and row interaction.

Usage

Default

Sortable data table
IDNameScoreStatus
1Alice91Pass
2Bob75Pass
3Charlie58Fail
4Dana84Pass
<DataTable
  data={sampleData}
  columns={sampleColumns}
  theme="primary"
  striped={true}
/>

Props

Sortable data table
PropTypeDefaultDescription
dataArray<{ id: number; name: string; score: number; passed: boolean; }>-Array of row data objects to render in the table.
columnsArray<{ key: string; label: string; sortable: boolean; render?: (value: any) => React.ReactNode; }>-Array of column definitions describing header, field, and cell rendering.
theme"primary" | "secondary" | "tertiary" | "quaternary" | "clear"Configured DefaultTheme variant for the table (primary, secondary, etc.).
state"" | "success" | "error" | "warning"-State style for the table (success, warning, error, or empty).
rounding"none" | "small" | "medium" | "large"Configured DefaultRounding style for the table (none, small, medium, large).
shadow"none" | "light" | "medium" | "strong" | "intense"Configured DefaultBox shadow style for the table (none, light, medium, strong, intense).
stripedbooleantrueIf true, applies alternating row background stripes.
outlinebooleanfalseWhether the table uses an outlined style.
onRowClick(row: { id: number; name: string; score: number; passed: boolean }) => void-Callback fired when a row is clicked.
onSortChange(key: string, order: string) => void-Callback fired when sorting changes.
defaultSortKeykeyof T-Default key to sort on initial render.
defaultSortOrder"asc" | "desc""asc"Default sort order.
serverSortbooleanfalseEnables server-side sorting.
data-testidstring"dat-table"Test ID for targeting the component in tests.
classNamestring-Additional CSS class names for the DataTable container.