Edit page

Table

Table presents complex tabular data in an easy-to-scan way.

Basic Usage

To implement the Table component, you need to import it first:

import { Table } from '@react-ui-org/react-ui';

And use it:

See API for all available options.

General Guidelines

  • Keep headers short so users can quickly scan the content of the table. Just one or two words should be enough.

  • Tables are good for displaying complex tabular data. For simpler data sets or even plain key-value pairs, consider using the Grid component.

  • Tables make lots of information easier to scan and compare. If you have fewer sections and want to emphasize each group more, consider using Cards.

Responsive Tables

The easiest way to make tables responsive is to wrap them with the ScrollView component in the horizontal mode.

Sortable Columns

The Table supports sorting indicators by adding a simple configuration.

⚠️ The Table component only provides necessary visual support for sorting. Aside from icons, you must provide the comparing functionality yourself if you aren't rendering already sorted data. The reason for this decision is that client often does not have access to the full dataset.

The following is an example of custom sorting function executed on the client.

API

Prop nameTypeDefaultRequiredDescription
columnsArray<{ "format": "Function", "isSortable": "Boolean", "label": "string", "name": "string" }>true

Table data columns, optionally sortable. The format function can be used to process the column data before displaying them.

idstringundefinedfalse

ID of the root HTML element. It also serves as base fo nested elements:

  • <ID>__headerCell__<COLUMN_NAME>
  • <ID>__headerCell__<COLUMN_NAME>__sortButton
  • <ID>__bodyCell__<COLUMN_NAME>__<ROW_ID>
rowsArray<{}>true

Table data rows, each object key must match a column name

sort{ "ascendingIcon": "node", "column": "string", "descendingIcon": "node", "direction": "'asc' │ 'desc'", "onClick": "Function" }nullfalse

Sorting configuration required to make columns sortable.