@spark-web/data-table v5.0.0
title: DataTable storybookPath: data-display-data-table
isExperimentalPackage: true
The DataTable component presents a list of data in table form.
It uses @tanstack/react-table as a dependency to implement data selection
and filtering capabilities. As such, certain table options are available as
DataTable props. For example, the items and columns prop are required
options.
Currently supported features from @tanstack/react-table are the following:
- Row selection
- Multi-row selection
- Row expansion
- Column visibility
However, certain defaults have been set for the component:
enableHidingis enabled by default;enableMultiRowSelectionis disabled by default, meaning row selection defaults to single-row;enableRowSelectionis automatically enabled when a callback value is passed inonRowSelectionChange.- The
dataproperty in React Table options is renamed toitemsto align with the rest of Spark Web's usage ofdataas a data attribute.
Example
<DataTable
items={[
{
id: 1,
name: 'Ken Adams',
category: 'Solar System',
amount: 3500,
},
]}
columns={[
{
id: 'id',
accessorKey: 'id',
header: 'ID',
cell: info => <Text size="small">{info.renderValue()}</Text>,
},
{
id: 'name',
accessorKey: 'name',
header: 'Name',
cell: info => <Text size="small">{info.renderValue()}</Text>,
},
{
id: 'category',
accessorKey: 'category',
header: 'Category',
cell: info => <Text size="small">{info.renderValue()}</Text>,
},
{
id: 'amount',
accessorKey: 'amount',
header: 'Amount',
cell: info => <Text size="small">{info.renderValue()}</Text>,
},
]}
/>Props
DataTable
10 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
12 months ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
10 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago