TableData

Designer doc
This component wraps Table component with higher-level abstraction and renders based on column.
The most common problem faced when using standard html table API is the code for th and td are so far away. Imagine you have a table with 20 columns, it’s rather difficult to maintain the correct order during development, it’s a bug prone API.
<thead> <tr> <th>A</th> ... <th>Z</th> </tr> </thead> <tbody> <tr> <td>1</td> ... <td>26</td> </tr> </tbody>
To solve this problem, what would it look like if we render based on column?
<table> <column title="A">1</column> ... <column title="Z">26</column> </table>
Isn’t it easier to read and maintain?

Example

Basic Usage
Using Column component, you can specify title and render prop. Extraneous props given to Column will be forwarded to TableCell component.
View code
Rows Selection
You can use ColumnSelection component for row selection. In example blow, it uses value and onChange to control and receive callback of selection changes. However, you can also pass onSelect, onSelectAll, onDeselect, and onDeselectAll to have grainer control of the selection behaviour.
View code
Disabled Rows Selection
View code
Accessible Row Click and Selection
One common use case of table is that clicking one row redirect to another page - behaves like a Link. However, <a> cannot be used to replace <tr>. So, our best option is to ensure that table rows that behave like a link are still accessible for keyboard users - which is to click when keyboard Enter, similar to button.
Pressing Space will also select the row if the table has a ColumnSelection.
View code
Pagination
TablePagination wraps Pagination and Select components, thus it has a very opinionated style and usage. You can pass this component to TableData’s footer prop and control the props you need to it.
View code
By default, page size options are 10, 20, 30 and 40, and the row is hidden if total row is fewer than the smallest option. You can customize sizes prop and set hidden to false to keep it visible.
Moreover, if you’re working on localisation, you can customize the individual components like example below:
View code
Loading
You can use loading prop to display Skeleton when the data is still loading. By default the loadingRowsCount is 5. You can also customize each column loading component with renderLoading.
View code
Empty Placeholder
You can specify emptyPlaceholder prop to customize the display when there’s no data.
View code
Conditional Rendering
To hide a Column component, you can either conditionally render it or to use hidden prop. This hidden props simply helps writing the jsx cleaner. You can also use React.Fragment, TableData can flatten it for you and render it accordingly.
View code
Composition
TableData component allows you to compose columns. Column component is basically like a TableCell, but it defines both title and render prop at the same time. Therefore, keep in mind that Column element is duplicated by TableData internally.
Below example demonstrates:
  • ColumnAddress: How you can achieve merged cell
  • ColumnName: Combine two (or more) Columns and reuse
View code
Expandable Table
You can use TableExpandButton component for expandable table. You also need to specify renderExpandableRow to define what to render inside the expandable row. You can control when to render the expandable row using isExpandable properties.
TableExpandButton can also be rendered inside the header to expand/collapse all the expandable row of the table.
View code
Tree Table
Display tree structure data in Table using the render function that is exposed by renderExpandableRow. You can render and control the position of the expand button for expanding the row by rendering TableExpandButton component inside the Column.
If rendered inside the header, TableExpandButton will only expand/collapse all the first level of the tree table.
View code
Caveat
For tree table, users need to control the expandedRows state manually to expand/collapse all layer of expandable rows inside the tree table.
View code
Complete Example
View code

References

API

Column
Prop nameTypeDefaultDescription
alignTextAlign
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
cellProps(record: any, index: number) => TableCellProps
depthnumber0
ellipsisboolean
hiddenboolean
indexnumber
loadingboolean
Determines whether the Column is in a loading state, showing skeleton placeholders.
recordany
render(record: any, index: number) => ReactNode
renderLoading(record: any, index: number) => ReactNode() => <Skeleton variant="rect" width="70%" height="100%" />
Customize the component to render on loading state
stickyColumnStickyPositions | ColumnStickyPositions[] | { left?: number; right?: number; }
titleReactNode
titlePropsTableCellProps
ColumnSelection
Prop nameTypeDefaultDescription
alignTextAlign
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
cellProps(record: any, index: number) => TableCellProps
depthnumber
ellipsisboolean
hiddenboolean
indexnumber
isDisabled(row: any, index: number) => boolean
loadingboolean
Determines whether the Column is in a loading state, showing skeleton placeholders.
onChange(value: RowKey[], valueObjects: any[]) => void
valueObjects will be returned based on the object data ever received by the TableData component.
undefined will be returned in place of the object if TableData component never received object with the particular key.
onDeselectSelectionCallback<RowKey>
onDeselectAllAllSelectionCallback<RowKey>
onSelectSelectionCallback<RowKey>
onSelectAllAllSelectionCallback<RowKey>
recordany
render(props: RenderParams<any>) => ReactNode<T extends unknown>({ children }: RenderParams<T>) => children
renderLoading(record: any, index: number) => ReactNode
Customize the component to render on loading state
renderTitle(props: { children: ReactElement<any, string | JSXElementConstructor<any>>; }) => ReactNode({ children }: { children: ReactElement }) => children
stickyColumnStickyPositions | ColumnStickyPositions[] | { left?: number; right?: number; }
titlePropsTableCellProps
valueRowKey[]
TableData
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
bodyPropsTableBodyProps
dataany[]
emptyPlaceholderReactNode<Result image={<EmptyBox size={64} />} description="No data" />
expandedRowsRowKey[]
footerReactNode
headPropsTableHeadProps
headRowPropsTableRowProps
isExpandable(record: any, index: number) => boolean
loadingboolean
Determines whether the table is in a loading state, showing skeleton placeholders.
loadingRowsCountnumber5
Specifies the number of rows to display in the loading state.
onChangeExpandedRows(expandedRows: RowKey[], valueObjects: any[]) => void
renderExpandableRowRenderExpandableRow<any>
renderRowRenderRow<any>
rowKey(record: any, index: number) => RowKey
tablePropsTableProps
TableExpandButton
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
colorTypeColorTypes
Set color based on theme. If color is specified, that prop is used instead of this.
disabledboolean
Equivalent to button's disabled property.
isExpandableboolean
keyboardClickKeysstring[]
loadingboolean
onBlurFocusEventHandler<HTMLDivElement>
onClickMouseEventHandler<HTMLDivElement>
onKeyDownKeyboardEventHandler<HTMLDivElement>
onKeyUpKeyboardEventHandler<HTMLDivElement>
onMouseDownMouseEventHandler<HTMLDivElement>
onMouseLeaveMouseEventHandler<HTMLDivElement>
onMouseUpMouseEventHandler<HTMLDivElement>
onReleaseEventHandler<SyntheticEvent<HTMLDivElement, Event>>
Callback that's triggered after click i.e. mouseup and keyup of enter or space.
onTouchEndTouchEventHandler<HTMLDivElement>
onTouchStartTouchEventHandler<HTMLDivElement>
radiusstring
renderIcon(props: { depth: number; isExpanded: boolean; }) => ReactNode
sizeIconButtonSizessmall
tooltipReactNode
tooltipPropsOmit<TooltipProps, "title" | "children">
variantIconButtonVariants
TablePagination
Prop nameTypeDefaultDescription
alignmentPaginationAlignments
Controls how the pagination items (like pages or page text) are aligned in the main container.
  • Center (default): Page items appear in the middle.
  • Right: Page items float to the right, left area can hold other items.
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
childrenReactNode
React children that can be used to override or extend the default pagination items. For example, you can pass <PaginationList /> or <PaginationPageText /> here.
currentnumber
The controlled current page number (1-based). If used, initialCurrent is ignored and the component becomes controlled.
initialCurrentnumber
The initial (uncontrolled) current page number. Defaults to 1.
initialNavSpannumber
initialPageSizenumber20
leftContainerPropsDivProps
leftElementReactNode
Defaults to showing total pages and selected items for non-minimal variants.
navSpannumber
The controlled number of pagination elements to show (e.g., 7 shows a maximum of 7 page buttons). Must be an odd number greater than 3 for best display.
numSelectednumber
(Optional) Number of selected items (out of totalRow). Used by default to display information like "x selected".
onChange(page: number) => void
A callback that fires when the current page changes (e.g., user navigates to a new page). Receives the new page number as its argument.
onNavSpanChange(navSpan: number) => void
onPageSizeChange(pageSize: number) => void
pageSizenumber
The controlled page size (number of items per page). If used, initialPageSize is ignored and the component becomes controlled.
rightContainerPropsDivProps
rightElementReactNode
Defaults to showing page navigation for non-minimal variants.
sizesnumber[]
Selectable page sizes.
totalRownumber
The total number of rows (items) across all pages. This is used to calculate the number of pages.
variantPaginationVariantsoutlined
The variant of pagination style to use.
  • Outlined (default): Shows outline styling for buttons.
  • Minimal: Shows a simpler pagination, often with only page text or partial controls.
TableRowClickable
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
indexnumber
isSelectedboolean
    Example
    Example
    Basic Usage
    Basic Usage
    Rows Selection
    Rows Selection
    Disabled Rows Selection
    Disabled Rows Selection
    Accessible Row Click and Selection
    Accessible Row Click and Selection
    Pagination
    Pagination
    Loading
    Loading
    Empty Placeholder
    Empty Placeholder
    Conditional Rendering
    Conditional Rendering
    Composition
    Composition
    Expandable Table
    Expandable Table
    Tree Table
    Tree Table
    Complete Example
    Complete Example
    References
    References
    API
    API
    Column
    Column
    ColumnSelection
    ColumnSelection
    TableData
    TableData
    TableExpandButton
    TableExpandButton
    TablePagination
    TablePagination
    TableRowClickable
    TableRowClickable
Coral is a thoroughly developed design system widely adopted by developers and designers for creating beautiful and user-friendly Sea internal products.

Copyright © 2018-2025 Sea Labs