Table
Table containers allow merchants to view a vertical list of items with property values and related actions.
Anatomy
The Table is designed to easily integrate with other components to create the view. You must understand the concept of the DataView Pattern before reading this section.
const { getBodyCell, getHeadCell, getTable, data } = useTableState<T>({
status,
columns,
items,
})
<Table {...getTable()}>
<THead>
{columns.map((column) => {
return <THeadCell {...getHeadCell(column)} />
})}
</THead>
<TBody>
{data.map((item) => {
return (
<TBodyRow key={item.id}>
{columns.map((column) => {
return <TBodyCell {...getBodyCell(column, item)} />
})}
</TBodyRow>
)
})}
</TBody>
</Table>Styling
The table and its composites accepts a className as property.
<Table className="custom-class" />
<THead className="custom-class" />
<THeadCell className="custom-class" />
<TBody className="custom-class" />
<TBodyRow className="custom-class" />
<TBodyCell className="custom-class" />Data Attributes
TableBodyRow
The clickable attribute is true whether the onClick property is passed:
[data-clickable="true"][data-clickable="false"]
The selected attribute is true whether the selected property is passed:
[data-selected="true"][data-selected="false"]
TableCell
The clickable attribute is true whether the onClick property is passed:
[data-clickable="true"][data-clickable="false"]
The fixed attribute is true whether the column.fixed property is passed:
[data-fixed="true"][data-fixed="false"]
Accessibility
This component implements the Table pattern.