Skip to main content

TableV2


TableV2 is the new version of the Atlas Table.

Example

Live Editor
Result
Loading...

Variants

Alignment

left, center and medium are the supported alignments, accessed using align prop under columns, left as default.

Live Editor
Result
Loading...

Column Resizing

The Table supports the column resizing function. You can use isResizable prop for making desired columns resizable. If you want to limit resizable column width value, you can use for the column maxWidth property.

You can use the onColumnResized callback property to get the new width of the column that was resized. The callback will be passed a column argument which is of type TableColumn.

You can use the minWidth and maxWidth properties to limitization the reached resized value. For more information pleace check the Min and Max width example

Live Editor
Result
Loading...

Compact Mode

There is a compact mode enabled by setting compact to true. Here we will be reducing the padding by half from left and right.

Live Editor
Result
Loading...

Custom Cell Renderer

There are Header, Footer, Cell property within the column configuration. With them you can define the custom render function for the header, the footer and a table cell accordingly.

Live Editor
Result
Loading...

Custom Cell Renderer on Row Hover

If you want to update your custom Cell component when the row it belongs to changes, you can use the getHoveredRowId method to get the id of the row currently being hovered.

Live Editor
Result
Loading...

Custom backgroundColor for the Cells

Changing the default cell background color requires passing custom cell markup. Since table cells have a default padding, in order to render a custom cell that takes the full cell width and height, it must be turned off by setting hasPadding to false.

Live Editor
Result
Loading...

DND Column re-ordering

The Table supports the drag-and-drop column re-ordering function. You can use isDraggable prop for making desired columns draggable for re-ordering.

You can also use onColumnRearrange callback property to get an ordered array of column accessors as a first argument and perform any action after column is rearranged.

Live Editor
Result
Loading...

Empty State

You can add an Empty State by using prop emptyState. It is shown if there is no data.

Live Editor
Result
Loading...

First and Last Column padding

You can align first and last columns using the firstColumnLeftPadding & lastColumnRightPadding props under visualProperties.

Live Editor
Result
Loading...

The table also supports the footer cells by adding Footer in column options.

Live Editor
Result
Loading...

Footerless

The prop isFooterless is used for hiding table footers.

Live Editor
Result
Loading...

Flex Table

The prop flex supports the flex layout feature by using width as the flex-basis and flex-grow. This feature becomes useful when implementing both virtualized and resizable tables that must also be able to stretch to fill all available space

You can also add disableResizing: true to column option to create a fixed width column. That column will not grow to fill positive free space.

info

To deal with the core column options width, minWidth, maxWidth in a flex table, you should pay the attention as follows:

  • minWidth is only used to limit column resizing. It does not define the minimum width for a column.
  • width is used as both the flex-basis and flex-grow. This means that it essentially acts as both the minimum width and flex-ratio of the column.
  • maxWidth is only used to limit column resizing. It does not define the maximum width for a column
warning

Flex table doesn't support column virtualization. Please be careful with number of columns will be rendered.

Live Editor
Result
Loading...

Global Search Filter

You can use this feature to globally search through all columns in the table. To exclude specific columns from global searching you can use the disableGlobalFilter property in your column object.

Live Editor
Result
Loading...

Header Actions

Header cells support using additional actions, such as an Icon Button for setting filters on the specific column.

As shown in the example, you can use the headerActions property inside the column object to assign custom actions to your column.

headerActions accepts a ReactNode type value, which means you can compose your custom components for this area.

info

It's recommended to exclusively employ the IconButton component as the action trigger element within the headerActions. Moreover, it's essential to ensure that all IconButtons adhere to a uniform size="small" prop. While exceptions can be contemplated, they should undergo a meticulous review process to ensure compatibility.

info

It's recommended to use isAutoWidth: true in the Header options when the space is not enough for actions.

Live Editor
Result
Loading...

Header Alignment

By default, header cell and column cells are aligned according to align property but there're use-cases when header cell needs a different alignment (e.g. RTL text direction). To align header-cell, alignHeader property can be specified for any column within columns array.

The alignHeader property supports the following options (please refer to the table below which shows all of supported options):

  1. left - default
  2. left-reversed
  3. right
  4. right-reversed
  5. center
  6. center-reversed
  7. space-between
  8. space-between-reversed
Live Editor
Result
Loading...

Header Groups

To use the grouped header feature, you must configure your columns as nested columns, as in the example below.

Live Editor
Result
Loading...

You can visually hide your group headers with the hideHeaderGroupTitle prop.

Live Editor
Result
Loading...

Header Group Bordered

You can set border based on grouping using areColumnGroupsBordered prop.

Live Editor
Result
Loading...

Header Menu

You can display a menu in header cells by providing your menu content with headerMenuItems property. You can see the example usage of the headerMenuItems property below.

The table uses the Action Menu component inside the header cells. You can also check the Action Menu component examples to get more info about different usages of menu content.

Live Editor
Result
Loading...

Headerless

The prop isHeaderless is used for hiding table headers.

Live Editor
Result
Loading...

Hover Highlighting

isHoverable prop can be used to toggle hover highlighting on table rows. By default, it is set to false.

Live Editor
Result
Loading...

Inline editing in Table

You can have inline editing in Table by using updateData prop and defining custom cell which includes needed editable component such as Input, ComboBox, Checkbox, etc.

Live Editor
Result
Loading...

Here is another example with more editable cells with ComboBox, Checkbox, SegmentedButton and nested Objects:

Live Editor
Result
Loading...

There are Header, Footer, Cell property within the column configuration. With them you can define the custom render function for the header, the footer and a table cell accordingly.

Live Editor
Result
Loading...

External link component (eg: react-router-dom)by adding property as and its attributes to, href, replace etc., within the data configuration. On top of it the Cell Renderer can be used for Custom Link cells.

import { Link } from 'react-router-dom';

function MyTable() {
const columns = [
{
Header: 'First Name',
accessor: 'firstName',
Footer: () => 'Total'
},
{
Header: 'Last Name',
accessor: 'lastName',
width: 300,
Cell: ({ value }) => <a href="#">value</a>
}
];

const data = [
{
firstName: 'Just a name',
lastName: 'Some lastName',
as: Link,
to: 'https://www.example.com'
},
{
firstName: 'Another name',
lastName: 'Another lastName'
as: Link,
to: {
pathname: "/courses",
hash: "#courses",
}
},
{
firstName: 'Random name',
lastName: 'Random lastName',
as: Link,
to: {
pathname: "/courses",
search: "?sort=name",
hash: "#random",
},
target: '_blank'
}
];

return (
<TableV2 data={data} columns={columns} />
);
}

Loading More Data (aka Infinite loading)

Table supports infinite loading by calling onLoadMoreData callback when Table gets scrolled to the end. To integrate infinite loading with React Query please refer to useInfiniteQuery hook and this example.

Live Editor
Result
Loading...

Loading State

You can active a loading state for the table by passing isLoading to be true. This helps users to see a skeleton cell when data is loading.

Also the loader height adapts to the typeScales of cellTypeScale and width is random, and also adapts the column alignments.

Live Editor
Result
Loading...

Min and Max width

The table supports a custom minimum width option for desired columns. You can use the minWidth property for each column to change the minimum width value. If you do not use the minWidth property for the column, column will take the minWidth 150px width value by default.

The table supports a custom maximum width option for desired columns. You can use the maxWidth property for each column to change the maximum width value. If you do not use the maxWidth property for the column, column will take the maxWidth 500px width value by default.

Live Editor
Result
Loading...

Nested Rows

You can have nested rows by adding subRows to data as the following example.

You can use the following callbacks to customize toggle in expandable rows by passing them to the Cell render prop .

  • toggleRowExpanded(rowId, isExpanded?): toggle a specific row.
  • toggleAllRowsExpanded(isExpanded?): toggle all rows.

You can add prop autoResetExpanded to component to allow the expanded state to automatically reset if data changes, default is false.

Live Editor
Result
Loading...

Nested Rows Indentation

You can add or remove the indentation for the non-expandable rows of the table using isNestedTable prop

Live Editor
Result
Loading...

Nested Rows with Navigation

  • The Nested Rows also supports a navigation in the header, which able to collapse the expanded rows of its group data.
  • You need to define an array of headerNavigationItems. It will map the group data and the row depth.
warning

Header Navigation doesn't support isAutoWidth.

Live Editor
Result
Loading...

Page level Scrolling

When table height is set to full-height, page level scrolling is enabled. Please find the example below.

info

align on Table columns prop can't be used with flex at the same time unless the table takes the full width

Live Editor
Result
Loading...

Popover

You can display popover in header cell and, inside it, custom components by providing the popover object with the column where you want to show the popover. You can use the following options inside the popover object; iconName: specify the icon for the icon button which opens the popover. iconSize is an optional property for setting the icon size (small | medium). isIconHighlighted is an optional boolean property for highlighting the popover icon button. isPopoverOpen: is an optional boolean property for controlling popover visibility externally. onClick is an optional property to define the custom onClick function for the popover button. content is a required property for providing the content we want to show in popover area. You can send your custom component as popover content with this property.

You can also use the optional onPopoverClick callback. It's sent to parent component the id of the clicked popover button.

Live Editor
Result
Loading...

Row onClick handler

You can pass a method to the table that would return the Row object on click of a row.

warning
Be mindful of onClick events on the cell content when using this feature.
Check the code for an example of a cell with a button that includes a `e.stopPropagation` call to avoid triggering the row method when the button is clicked.
Live Editor
Result
Loading...

Row Selection (Checkboxes)

You can add the boolean prop rowSelection to component to allow row selection with checkboxes. Beside that, you can control the selection state with following props:

  • selectedRowId: Record<string, boolean> to set selected rows and subRows.
  • onRowSelect: (selectedRowIds: Record<string, boolean>) => void is a callback function when rows are selected.

You can also disable the row selection by adding prop disabled to row data.

info

If you want to use selectedRowId to check a row and its subRows, please add all subRow's ids to selectedRowId (not included disabled subRows).

❌ Incorrect: Only row id 2 was checked, its subRows were not checked.
<TableV2
height={300}
data={data}
columns={columns}
rowSelection
selectedRowIds={ '2': true }
onRowSelect={onRowSelect}
/>


✅ Correct: row id 2 was checked and its subRows were also checked.
<TableV2
height={300}
data={data}
columns={columns}
rowSelection
selectedRowIds={ '2.0': true, '2.1': true } // or { '2': true, '2.0': true, '2.1': true }
onRowSelect={onRowSelect}
/>

Following example is how to manage selection state from outside of table.

Live Editor
Result
Loading...

Moreover, you can set checkboxes column as sticky column by adding stickyRowSelection to table prop.

Live Editor
Result
Loading...

Row size

small, medium and large are the supported row sizes, accessed using rowSize prop, medium as default.

Live Editor
Result
Loading...

Row with Auto Height

As the default, the height of rows respect to the rowSize. But when autoRowsHeight prop is used, rows in the table will grow in respect to their content.

info

To remeasure the height of specific cell, you can use the callback measureRow(rowId, cellIndex) which is passed to Cell render prop.

warning

If migrating this feature from Table V1, the callback measureRow(rowId, cellIndex) will be a breaking change.

In the example below, typing in any of the ComboBox will grow the table row, measureRow has been used to remeasure the row height.

Live Editor
Result
Loading...

Sorting

The table always shows data in the provided order and the actual sorting functionality should be implemented on your side. You can specify the activeSorting to visually highlight the sorting for a column and onSortingChange to handle clicks within the header cell. onSortingChange will return the columnKey and sorting direction will be determined by the activeSorting you provide. You can disable sorting for a specific column by specifying sortable in the columns array.

You can also provide multiple values with activeSorting prop to visually highlight the active sorting of multiple columns. Please check initialSortingMultiple in the below example.

Live Editor
Result
Loading...

Sticky Columns

You can specify sticky field within the column configuration to make the column "stick" either to the left or to the right side of the table.

info

Columns with sticky: 'right' should be placed in the end of the columns array.

Live Editor
Result
Loading...

Table Height

The prop height supports value type with number and string. And it also supports full-height to allow Page level Scrolling.

note

if height is not providded, the height of table will be the height of the total rows but the rows are not virtualized. Therefore it's not recommended for large data.

Live Editor
Result
Loading...

Type Scales

Typescale is the combination of font-size, line-height, and letter-spacing. By default, the type scale of all cells is defined by the size variant of the table. Adding typeScales enforces a distinct type scale for the specific table cell(header, body or footer).

Live Editor
Result
Loading...

UnstickThreshold

This component supports the automatic limitation of sticky columns based on its width. You may need to use a more scrollable area for non-sticky columns when having both sticky and non-sticky columns together in the Table.

Use unstickThreshold to specify the percentage of the limitation for sticky columns. For instance, if unstickThreshold is 50, the Table will change sticky columns to non-sticky when the total width of sticky columns is greater than 50% of the table width.

Live Editor
Result
Loading...

UnstickResolution

This feature makes columns to be non-sticky if the window width resizes under a given value.

Use unstickResolution to activate this feature, as in the below example.

info

This feature is an additional feature of unstickThreshold. It is recommended to be used with the unstickThreshold while the Atlas responsive table feature is an upcoming plan.

Live Editor
Result
Loading...

Virtualized Rows & Columns

Table support virtualization of rows and columns as default, but except for Flex table.

Live Editor
Result
Loading...

Visual properties

visualProperties are used to show visual representation of records. For instance, showing bordered columns or greyBackgroundHeader.

Live Editor
Result
Loading...

Zebra Stripe

You can activate zebra-striping of rows by adding isStriped to the visualProperties. This helps users orient themselves in long and complex tables.

Live Editor
Result
Loading...

Custom Hooks

Custom Initial Widths

TableMeasurement is a custom hook of TableV2 to customize the Initial Column Widths by measuring the text content of each cell and return the array of new column widths.

By adding initialMinWidth, initialMaxWidth or isAutoWidth to the columns option, the hook will recalculate the minWidth, width, maxWidth and isResizable of the column, and overwriting the default behavior of these options.

warning

This hook only supports for the body cells which render their value (text content) from data, not support for custom cells without data value. Please be careful if body cells are using Custom Cell Renderer

info

More details please refer to Table Measurement

<TableMeasurement columns={columns} data={data}>
{({ isMeasuring, measuredColumns }) =>
!isMeasuring && (
<TableV2 data={data} columns={measuredColumns}/>
)
}
</TableMeasurement>

Return states

The hook returns TableMeasurementType as following:

StateTypeDesc
measuredColumnsTableColumnTypes[]The array of columns which is passed initially and including more: {id, width, minWidth, maxWidth, isResizable}
isMeasuringbooleantrue if the hook is measuring the column widths and hasn't returned the result

Examples

You can refer following examples for the usage.

initialMinWidth allows you to set initial width and minWidth of a column and able to resize to fit the longest content width (which is smaller than the initial width).

note

initialMinWidth will recalculate the width and minWidth of a column and overwrite the default behavior of these column options.

Live Editor
Result
Loading...

Examples

Cases of Auto Width

Auto Width Columns with unstickThreshold and sub Rows.

Live Editor
Result
Loading...

Props

NameTypeDefault
data *
The data array that you want to display on the Table. It should be memoized.
Record<string, unknown>[]
columns *
The core columns configuration object for the entire Table. It should be memoized.
TableColumnTypes[]
autoRowsHeight
Allow the height of body rows to grow respectively to content height
boolean
activeSorting
The sorting applied to the Table.
any
compact
Enable the compact version when true
boolean
emptyState
The props of Empty State component, it will be shown if there is no data
Omit<EmptyStateProps, "size" | "background" | "iconKey">
flex
It is used for using the Table with flex layout
boolean
getFilteredData
callback to get filtered data after global filter is applied
((filteredData?: any[]) => void)
isHeaderless
If set to true table headers will be hidden
boolean
isFooterless
If set to true table footers will be hidden
boolean
isHoverable
If set to true, the table body rows can show hover state
boolean
getHoveredRowId
pass this method to access the id of the row being hovered
((id: string) => void)
isLoading
Show loading state of the table
boolean
height
Visible table view height. The default value of this prop is the height of the total rows. If set to full-height, `100%` will be applied.
string | number
hideHeaderGroupTitle
If set to true table group header title will be hidden
boolean
isLoadingMoreData
table is loading more data
boolean
loadingMoreDataLabel
Custom label to be shown while loading more data
string
headerNavigationItems
Array of Navigation Items in header if having Sub rows
HeaderNavigationItem[]
onColumnRearrange
Callback prop onColumnRearrange when dropping column on rearrange
((columnsOrder: string[]) => void)
onColumnResized
Callback prop onColumnResized when column is resized
((column: any) => void)
onSortingChange
The handler will be called when a user clicks to sorting actions
((columnName: string) => void)
onPopoverClick
The handler will be called when a user clicks to icon for opening popover
((columnName: string) => void)
rowOnClickHandler
Handler that returns row data on click
((rowData: any) => void)
rowSize
The size of rows
"small" | "medium" | "large"
searchTerm
Search term to be used to do global filtering of data
string
typeScales
Provide type scales for the table head, body and footer
any
visualProperties
Provide visual properties to Table
any
updateData
The callback to use for updating table data. the use case is inline editing mode of Table which requires updateData callback
Record<string, unknown>[]
hasMoreData
There's still some data to be loaded
boolean
onLoadMoreData
It's called when user scrolls to the end of table in order to load more data
((startIndex?: number, stopIndex?: number) => void | Promise<void>) | undefined
unstickThreshold
The maximum percentage value that fixed columns can occupy over the table width. If the total fixed columns width exceeds this value, they will automatically turn into unfixed columns
number
unstickResolution
The number value to make columns unstick if the window width is smaller than this
number
rowSelection
Allow to select rows with checkboxes
boolean
selectedRowIds
Allow to set initial selected rows
Record<string, boolean>
stickyRowSelection
Allow to set checkboxes column as sticky column.
boolean
onRowSelect
A callback for row selection
((selectedRowIds: Record<string, boolean>) => void)
isNestedTable
A boolean to know if the table is nested
boolean
autoResetSelectedRows
A boolean to allow the selectedRowIds state to automatically reset if data is changed, default is false.
boolean
autoResetExpanded
A boolean to allow the expanded state to automatically reset if data is changed, default is false
boolean
data-{foo}
Data attributes can be used by testing libraries to retrieve components or assert their existence
string
* - the prop is required.