Skip to main content

Table

import { Table } from '@enmovil/ui-design-system';

A table for small datasets, with a scrollable body and fixed columns. Its row type is currently fixed to key, name, age and address, so use Grid for real data.

Properties​

PropertyTypeRequiredDefaultAllowed valuesDescription
columnsColumnsType<DataType>Yes——Columns of the table, each with a title, the dataIndex of the row field it shows, and optionally a width, a fixed side, a sorter or a custom render.
dataSourceDataType[]Yes——Rows of the table. The body scrolls vertically past 300px and horizontally when the columns are wider than the table.
paginationfalse | TablePaginationConfigNo——Paging settings, such as { pageSize: 5 }, or false to show all rows without paging. Without it, rows are shown 10 to a page.

dataSource​

An array of objects (DataType). Each object has these fields:

FieldTypeRequiredDescription
keyReact.KeyYesUnique key of the row.
namestringYesName value of the row, shown by a column whose dataIndex is name.
agenumberYesAge value of the row, shown by a column whose dataIndex is age.
addressstringYesAddress value of the row, shown by a column whose dataIndex is address.
Other attributes

Table passes 44 further attributes through to the underlying element. They aren't part of the supported API and may change between releases, so use only the properties listed on this page.

Events​

NameSignatureWhen it fires
onChange((pagination: TablePaginationConfig, filters: Record<string, FilterValue | null>, sorter: SorterResult<DataType> | SorterResult<...>[], extra: TableCurrentDataSource<...>) => void)Fires when the page, a sort order or a column filter changes.
onScrollUIEventHandler<HTMLDivElement>Fires when the table body scrolls. Useful for loading more rows at the bottom.
onRowGetComponentProps<DataType>Returns per-row handlers (onClick, onDoubleClick, onMouseEnter, onMouseLeave, onContextMenu). Use it for row click-through and hover highlights.
onHeaderRowGetComponentProps<readonly ColumnType<DataType>[]>Returns handlers for the header row, in the same shape as onRow.

Children​

Table does not accept children.

Variants​

Loading examples…

Playground​

Change the controls to see how the properties affect the component. Values the controls don't cover come from the Default Table example.

Loading playground…

Storybook​

Open Table in Storybook to try every story with the full set of controls.