Skip to content

CdsTable

A table shows large sets of records in columns and takes the data work off your hands: sorting, filters, pagination, row selection and expansion, a pinned header and pinned columns. Columns are described by the columns prop, the records by the data prop.

Storybook GitLab Figma
Test coverage: 0% — low coverage
API in specs
0 / 72 props, events, slots and exposed members with a test
Test cases
13 unit · 0 browser
Code coverage
15.2% lines · 7.4% branches measured in v4.0.0-alpha.13
A11y (axe)
50 recommendations in 39 stories measured in v4.0.0-alpha.11

For a plain list of similar items without columns, use CdsList; for a hierarchy without tabular data, use CdsTree.

The table's features are split across sections — they are collected in Documentation sections and in the menu on the left. This page covers the basics and the API.

Anatomy ​

Around the table there are the header, toolbar and footer slots and built-in pagination (the pagination prop). The table itself consists of a column header and rows with cells.

Variations ​

Showing data ​

A minimal table: an array of column descriptions in columns, the records in data. The row key comes from the record's key field or from the row-key prop.

The column's align property aligns the content — numeric values are conventionally aligned to the right.

Sizes ​

The size prop controls the density: md is the default, sm and xs are for data-dense screens.

Rows ​

The row-class-name property computes a row class from the record: the built-in cds-table--striped class alternates the background, cds-table__row--warning and cds-table__row--error add a status highlight. The hovered prop highlights the row under the cursor.

Cell content ​

The column's ellipsis property truncates long text to a single line with an ellipsis — in cells and in headers alike.

Responsiveness ​

The column's responsive property lists the breakpoints at which the column is visible — secondary columns get hidden on narrow screens.

Guidelines ​

Documentation sections ​

  • Structure and headers — header grouping, merged cells, the slots around the table, column widths and declarative column descriptions.
  • Pinning and scrolling — pinning the header and columns while scrolling, horizontal scroll buttons.
  • Filters and sorting — column filters, multiple sorting, resetting and a custom filter panel.
  • Row selection — checkboxes, operations on the selected set, custom selection menu items.
  • Expansion and trees — expandable rows, nested tables and tree data.
  • Editing — editable cells, rows and the whole table.
  • Drag and drop — dragging rows and columns.
  • Scenarios — server-side data and ready-made recipes for product tables.

API ​

CdsTable ​

Props

NameTypeDefaultDescription
borderedboolean | undefinedfalseShow every table border
borderlessboolean | undefinedfalseRemove every table border
canExpandableboolean | undefinedfalseRows can be expanded
childrenColumnNamestring | undefined'children'Name of the property holding the child records
columnDraggableNTable.NDraggable.TColumnDraggable<any> | undefined—Column drag and drop. true or a configuration object { icon, disabled, allowDrop }. Reordering only happens among siblings inside the same group; the consumer changes the order in the @column-reorder handler.
columnsNTable.NColumn.TColumns<any> | undefined—Table columns
componentsNTable.NCustomize.TableComponents<any> | undefined—Override the default table components
customHeaderRowNTable.NCustomize.TGetComponentProps<NTable.NColumn.IColumn<any>[]> | undefined—Sets the properties for every header row
customRowNTable.NCustomize.TGetComponentProps<any> | undefined—Sets the properties for every row
dataany[] | undefined—Array of records to show in the table
defaultExpandAllRowsboolean | undefinedfalseAll rows are expanded by default
defaultExpandedRowKeysNTable.TKey[] | undefinedundefined as ITableProps['defaultExpandedRowKeys']Keys of the rows expanded by default
disabledboolean | null | undefinednullDisabled state
expandColumnWidthnumber | undefined—Width of the expand column
expandedRowClassNameNTable.NRow.TClassName<any> | undefined—Classes for rows in the expanded state
expandedRowKeysNTable.TKey[] | undefinedundefined as ITableProps['expandedRowKeys']Keys of the currently expanded rows (supports v-model)
expandedRowRenderNTable.NExpand.TExpandedRowRender<any> | undefined—Render function for every expanded row
expandFixedNTable.TFixed | undefined—Pin the expand column (left | right | boolean)
expandIconNTable.NExpand.TRenderExpandIcon<any> | undefined—Custom expand icon
expandIconColumnIndexnumber | undefined—Index of the column that holds the expand icon
expandRowByClickboolean | undefinedfalseExpand the row by clicking anywhere in it
footerNTable.NRender.TPanelRender<any> | undefined—Render function for the table footer
getPopupContainerNTable.NCustomize.TGetPopupContainer | undefined—Container that dropdowns are rendered into
headerNTable.NRender.TPanelRender<any> | undefined—Render function for the table title
hoveredboolean | undefinedfalseHighlight the row on hover
idstring | undefined—Table identifier
indentSizenumber | undefined20Indent size in pixels for each nesting level
loadingboolean | undefinedfalseTable loading state
localeNTable.ILocale | undefined—Table localization (overrides the strings of the global locale)
paginationfalse | NTable.NPagination.IProps | undefined—Table pagination configuration
readonlyboolean | null | undefinednullRead-only state
rowClassNamestring | NTable.NRow.TClassName<any> | undefined—Row classes
rowDraggableNTable.NDraggable.TRowDraggable<any> | undefined—Row drag and drop. true or a configuration object { icon, disabled, allowDrop }. Reordering only happens between siblings of the same parent; the consumer changes the order in the @row-reorder handler.
rowExpandable((record: any) => boolean) | undefined—Whether the row can be expanded
rowKeystring | NTable.NRow.TGetRowKey<any> | undefined'key'Unique row key — a string or a function returning a string
rowSelectionNTable.NRow.IRowSelection<any> | undefined—Row selection configuration
scroll(NTable.TScroll & { scrollToFirstRowOnChange?: boolean | undefined; }) | undefined—Whether the table can be scrolled
showExpandColumnboolean | undefined—Show the expand column
showHeaderboolean | undefined—Whether to show the table header
showSorterTooltipNTable.NSorter.TTooltip | undefinedtrueWhether to show sorting tooltips in the header. You can pass an object with CdsTooltip properties.
sizenumber | "xs" | "sm" | "md" | "lg" | "xl" | undefined'md'Size of the component
sortDirectionstring[] | undefined—Sorting of the table data. 'ascend' | 'descend'
stickyboolean | NTable.NSticky.ISticky | undefined—Sticky behavior for the header and the scrollbar
tableLayoutNTable.TLayout | undefined—Fixed or auto layout
themestring | undefined—Component theme
toolbarNTable.NRender.TPanelRender<any> | undefined—Render function for the table toolbar
transformCellTextNTable.NCell.TTransformCellText<any> | undefined—Transform the text inside a cell

Events

NameTypeDescription
change[pagination: NTable.NPagination.IProps, filters: Record<string, NTable.TFilterValue | null>, sorter: NTable.ISorterResult<any> | NTable.ISorterResult<any>[], extra: NTable.ICurrentData<any>]Fired when the pagination, the filters or the sorting change.
columnReorder[info: NTable.NDraggable.IColumnReorderInfo<any>]Fired when a column is dragged. The consumer changes the order of the columns.
expand[expanded: boolean, record: any]Fired when a row is expanded or collapsed.
expandedRowsChange[expandedKeys: NTable.TKey[]]Fired when the set of expanded rows changes.
resizeColumn[width: number, column: NTable.NColumn.IColumn<any>]Fired when a column is resized.
rowReorder[info: NTable.NDraggable.IRowReorderInfo<any>]Fired when a row is dragged. The consumer changes the order of the data.
update:expandedRowKeys[expandedKeys: NTable.TKey[]]Fired when the expanded rows are updated (v-model).

Slots

NameTypeDescription
bodyCell{ text: any; value: any; record: any; index: number; column: NTable.NColumn.IColumn<any>; }Custom render of a table body cell.
customFilterDropdownNTable.NColumn.IFilterDropdownProps<any>Custom filter dropdown of a column (used together with the column customFilterDropdown).
customFilterIcon{ filtered: boolean; column: NTable.NColumn.IColumn<any>; }Custom column filter icon.
defaultanyDeclarative column description with CdsTableColumn / CdsTableColumnGroup.
emptyTextanyContent shown when there is no data.
expandedRowRender{ record: any; index: number; indent: number; expanded: boolean; }Render of the expanded row content.
expandIconNTable.NExpand.IRenderExpandIconProps<any>Custom row expand icon.
footerreadonly any[]Table footer (the panel below the table).
headerreadonly any[]Table title (the panel above the table).
headerCell{ title: NTable.NColumn.TTitle<any>; column: NTable.NColumn.IColumn<any>; }Custom render of a table header cell.
summary{ pageData: readonly any[]; }Summary row of the table.
toolbarreadonly any[]Table toolbar (the panel above the table).

Exposed

NameTypeDescription
tableanyReference to the internal table instance — gives access to its methods and state.

CdsTableColumn ​

Slots

NameTypeDescription
default{ value: any; text: any; record: any; index?: number | undefined; renderIndex?: number | undefined; column: NTable.NColumn.IColumn<any>; }Custom render of a column cell.
filterIcon{ filtered: boolean; column: NTable.NColumn.IColumn<any>; }Custom column filter icon.
titleNTable.NColumn.ITitleProps<any>Column title.

CdsTableColumnGroup ​

Slots

NameTypeDescription
defaultanyColumns of the group (CdsTableColumn).
titleNTable.NColumn.ITitleProps<any>Title of the column group.