Data Table

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

Usage

Default

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

Props

Data table
TypeDescription
aria-describedbystringAccessible description reference for the table. Useful for tying helper or instructional text to the table.
aria-labelstringAccessible label for screen readers. Use this when there is no visible caption or heading tied to the table.
aria-labelledbystringAccessible labelledby reference for the table. Prefer this when a visible heading already labels the table.
captionstringOptional visible or screen-reader-only caption text for the table. A table caption is the preferred built-in table label.
classNamestringOptional class name for the table wrapper.
colCountnumberTotal column count override. Helpful when rendering dynamic or grouped columns in advanced cases.
columnsColumn<T>[]Array of column definitions.
dataT[]Array of row data objects.
data-testidstringOptional test ID for testing frameworks.
defaultSortKeykeyof TDefault key to sort by on initial render.
defaultSortOrder"desc" | "asc"Default sort order on initial render ('asc' | 'desc').
emptyMessagestringText shown when no rows are available.
getRowAriaDescription((row: T, index: number) => string)Optional row description for screen readers. Only used when rows are interactive.
getRowAriaLabel((row: T, index: number) => string)Optional accessible label for interactive rows. Only used when onRowClick is provided.
getSortAnnouncement((column: Column<T>, sortOrder: "asc" | "desc") => string)Live region text announced when sorting changes. Receives the active column and current order.
getSortAriaLabel((column: Column<T>, sortOrder: "asc" | "desc", isActive: boolean) => string)Accessible label for the sort buttons/controls. Receives the column label and current sort order.
hideCaptionbooleanWhether the caption should be visually hidden. Useful when you want semantic labeling without visible UI.
loadingbooleanWhether the table is currently loading data.
loadingMessagestringAccessible and/or visible loading message.
onRowClick((row: T) => void)Optional callback when a row is clicked.
onSortChange((key: keyof T, order: "asc" | "desc") => void)Function to handle server-side sorting.
outlinebooleanWhether to use outline styling.
roundingRoundingTypeRounding style for the table ('none' | 'small' | 'medium' | 'large' | 'full').
rowCountnumberTotal row count override. Helpful for virtualized or server-paginated tables.
rowKey((row: T) => string | number)Function to derive a unique key for each row.
serverSortbooleanWhether to enable server-side sorting.
shadowShadowTypeShadow style for the data table ('none' | 'light' | 'medium' | 'strong' | 'intense').
stateStateTypeState of the table ('success' | 'error' | 'warning' | 'disabled' | '').
stripedbooleanWhether to use striped row styling.
themeThemeTypeTheme used for styling the table ('primary' | 'secondary' | 'tertiary' | 'quaternary' | 'clear').