Skip to content

DataTable

DataTable

jsx
import DataTable from '@semcore/ui/data-table';
<DataTable />;

DataTableProps

& & {...}
NameTypeDescription
data Data for table
totalRowsnumber Count of total rows if table using virtual scroll. Needs for accessibility
use Table theme according to visual hierarchy on the page
sortDataTableSort<keyof [0]> Active sort object
onSortChangeDataTableChangeSort<keyof [0]> Handler call when request will change sort
defaultGridTemplateColumnWidthstring Value to describe width for each column. Could be overridden in the column.gtcWidth property. Use `auto` to automatically fit the table to the content, `1fr` for equal-width columns or any other value for the grid-template-column css property.
compactboolean Flag for compact view (smaller horizontal paddings)
sideIndents"wide" Size of paddings for the first and last columns in the table
loadingboolean Flag for showing spinner on table body
childrennever
expandedRowsSet<[number][keyof [number]]> Set of expanded rows (uniq id from them) This is mutable! variable because of table performance. Don't change the link on it.
virtualScroll Configuration for virtual scroll
columns Configuration for table columns including headers, sorting, and layout
headerProps Configuration for sticky headers, height, scroll bars, etc.
rowPropsDataTableBodyProps<, [number][keyof [number]]>["rowProps"] Function to add custom props to rows
renderCellDataTableBodyProps<, [number][keyof [number]]>["renderCell"] Custom cell renderer function
uniqueRowKeykeyof [number] Name of a unique key for each row data item
selectedRows[number][keyof [number]][] List of selected rows (uniqIds from a data array)
onSelectedRowsChange(selectedRows: [number][keyof [number]][], event: React.SyntheticEvent<>, opts: {selectedRowIndex: number; isSelected: boolean; row: DTRow<[number][keyof [number]]> }) => void Callback when row selection changes
renderEmptyData() => React.ReactNode For custom empty data widget.
renderCellOverlay() => React.ReactNode For adding an overlay over table cells.
accordionDurationnumber | [number, number] Duration for collapse/expand accordion rows in tables in ms.
accordionAnimationRowsRowPropsInner<, [number][keyof [number]]>["accordionAnimationRows"] List of animated rows in accordion.
accordionMode"toggle" | "independent" Whether multiple accordion items can be open at a time, or only one.
onAccordionToggle(type: "open" | "close", uniqRowKey: [number][keyof [number]], rowIndex: number) => void Handle open/close accordion. Work only with table-in-table accordions. In accordions with custom components use mount/unmount hooks in components.
limit {fromRow?: number; fromColumn?: number; renderOverlay: () => React.ReactNode } Defines a limit configuration
variant"default" | "card" Visual variant that adapts the table styling to different usage contexts
onExpandedRowsChange(expandedRows: Set<[number][keyof [number]]>) => void Handle change expanded rows
onResize Handling table container resizing.

CellRenderProps are passed to the renderCell prop of DataTable.

CellRenderProps

NameTypeDescription
dataKeystring The column key for the cell data
rowDTRow<> The complete row data object
column The column configuration object
rowIndexnumber Zero-based row index in the table
columnIndexnumber Zero-based column index in the table
columnNamestring | typeof ACCORDION The name/key of the column
valuestring | React.ReactElement Cell value
defaultRender() => React.ReactNode Function that returns the default cell rendering
isMergedRowsboolean Indicates if this cell spans multiple rows
isMergedColumnsboolean Indicates if this cell spans multiple columns
rawData The original unprocessed row data
isAccordionRowboolean Flag to show is the cell is in the accordion row
accordionRowIndexnumber Zero-based accordion row index

Released under the MIT License.

Released under the MIT License.