Table API
Import
Section titled “Import”Cimpress UI exports multiple components that you can use as building blocks to create a table. Listed below are basic components you’ll need for most tables:
Table: a wrapper component for the entire tableTableHeader: a wrapper component for all column headersTableHeaderRow: renders a single row withinTableHeaderTableHeaderCell: renders a single column header withinTableHeaderRowTableBody: a wrapper component for all data rowsTableBodyRow: renders a single row withinTableBodyTableBodyCell: renders a single cell withinTableBodyRowTableContainer: a scrollable container that allows tables to overflow in a responsive wayTableEmptyState: a special table cell that can be displayed when the table has no data
import { Table, TableBody, TableBodyCell, TableBodyRow, TableContainer, TableEmptyState, TableHeader, TableHeaderCell, TableHeaderRow,} from '@cimpress-ui/react';Building a table
Section titled “Building a table”Please follow our table guide to learn how to build tables with Cimpress UI components.
Accessibility notes
Section titled “Accessibility notes”Table follows the ARIA grid pattern. See the linked page for a list of available keyboard interactions.
Table is a single tab stop within the page’s tab order. Use the Tab key to navigate to the table, and the arrow keys to navigate between cells.
Table requires a textual label to remain accessible to assistive technologies. See our accessibility guide for more details.
Table has additional accessibility considerations depending on presented data and available interactions. Please follow our table guide when building your table to make sure it’s accessible to all users.
Interactive cell content
Section titled “Interactive cell content”Tables with interactive cell content should follow the rules below:
- Don’t mix interactive and non-interactive content within a single cell.
- Don’t use interactive controls that require arrow keys for basic operation (text fields, radio groups, etc.).
- This restriction doesn’t apply to collapsible lists hidden behind a trigger (selects, menus, etc.).
Certain screen readers, like NVDA and VoiceOver, don’t fully support the ARIA grid pattern. Users of these screen readers may experience difficulties navigating tables with interactive content.
API reference
Section titled “API reference”TableContainer
Section titled “TableContainer”Renders a scrollable container that allows a table to overflow in a responsive way.
- Ref<HTMLDivElement>
-
The
reftype for this component.
TableContainerProps
- ReactNode
children *
Section titled “ children * ” -
The contents of the container.
- string
-
The element's unique identifier. See MDN.
- boolean
data-cim-style-root
Section titled “ data-cim-style-root ” -
Use this attribute to "claim" the component tree for exclusive Cimpress UI usage.
- string
UNSAFE_className
Section titled “ UNSAFE_className ” -
Sets the CSS className for the element. Only use as a last resort. Use style props instead.
See styling guide.
- CSSProperties
UNSAFE_style
Section titled “ UNSAFE_style ” -
Sets the CSS style for the element. Only use as a last resort. Use style props instead.
See styling guide.
- string
aria-label
Section titled “ aria-label ” -
Defines a string value that labels the current element.
- string
aria-labelledby
Section titled “ aria-labelledby ” -
Identifies the element (or elements) that labels the current element.
- string
aria-describedby
Section titled “ aria-describedby ” -
Identifies the element (or elements) that describes the object.
- string
aria-details
Section titled “ aria-details ” -
Identifies the element (or elements) that provide a detailed, extended description for the object.
StyleProps
- Responsive<Spacing | "auto">
margin
Section titled “ margin ” -
The amount of margin applied to all edges of this component.
- Responsive<Spacing | "auto">
marginX
Section titled “ marginX ” -
The amount of margin applied to the left and right edges of this component. Takes priority over
margin. - Responsive<Spacing | "auto">
marginY
Section titled “ marginY ” -
The amount of margin applied to the top and bottom edges of this component. Takes priority over
margin. - Responsive<Spacing | "auto">
marginTop
Section titled “ marginTop ” -
The amount of margin applied to the top edge of this component. Takes priority over
marginYandmargin. - Responsive<Spacing | "auto">
marginRight
Section titled “ marginRight ” -
The amount of margin applied to the right edge of this component. Takes priority over
marginXandmargin. - Responsive<Spacing | "auto">
marginBottom
Section titled “ marginBottom ” -
The amount of margin applied to the bottom edge of this component. Takes priority over
marginYandmargin. - Responsive<Spacing | "auto">
marginLeft
Section titled “ marginLeft ” -
The amount of margin applied to the left edge of this component. Takes priority over
marginXandmargin.
Displays data in an organized, tabular way.
- Ref<HTMLTableElement>
-
The
reftype for this component.
TableProps
- ReactNode
children *
Section titled “ children * ” -
The contents of the table.
- number
totalRowCount
Section titled “ totalRowCount ” -
The number of rows in the full dataset, including headers.
Provide this value if your table presents a subset of rows, such as when using pagination. Use
-1if the number of rows is not known.You must provide
rowNumberon each table row iftotalRowCountis defined. - number
totalColumnCount
Section titled “ totalColumnCount ” -
The number of columns in the full dataset.
Provide this value if your table presents a subset of columns, such as when the user toggles column visibility. Use
-1if the number of columns is not known.You must provide
columnNumberon each table header cell iftotalColumnCountis defined. - RowSelectionMode
rowSelectionMode
Section titled “ rowSelectionMode ” - Defaults to 'none' .
The type of row selection that is allowed within the table.
- boolean
areAllRowsSelected
Section titled “ areAllRowsSelected ” -
Whether all of the table's rows are selected. The meaning of "all rows" is dictated by the consumer.
- boolean
areSomeRowsSelected
Section titled “ areSomeRowsSelected ” -
Whether some (but not all) of the table's rows are selected. The meaning of "some rows" is dictated by the consumer.
- (value?: boolean) => void
onAllRowsSelectionToggle
Section titled “ onAllRowsSelectionToggle ” -
A function called when the selection state of all rows should change.
If called without an argument, you are free to pick the new selection state based on your own logic. If called with an argument, you must set the selection state to the provided value.
- string
-
The element's unique identifier. See MDN.
- boolean
data-cim-style-root
Section titled “ data-cim-style-root ” -
Use this attribute to "claim" the component tree for exclusive Cimpress UI usage.
- string
UNSAFE_className
Section titled “ UNSAFE_className ” -
Sets the CSS className for the element. Only use as a last resort. Use style props instead.
See styling guide.
- CSSProperties
UNSAFE_style
Section titled “ UNSAFE_style ” -
Sets the CSS style for the element. Only use as a last resort. Use style props instead.
See styling guide.
- string
aria-label
Section titled “ aria-label ” -
Defines a string value that labels the current element.
- string
aria-labelledby
Section titled “ aria-labelledby ” -
Identifies the element (or elements) that labels the current element.
- string
aria-describedby
Section titled “ aria-describedby ” -
Identifies the element (or elements) that describes the object.
- string
aria-details
Section titled “ aria-details ” -
Identifies the element (or elements) that provide a detailed, extended description for the object.
TableHeader
Section titled “TableHeader”Renders a header section within a table.
- Ref<HTMLTableSectionElement>
-
The
reftype for this component.
TableHeaderProps
- ReactNode
children *
Section titled “ children * ” -
The header rows that belong to this table header.
- string
-
The element's unique identifier. See MDN.
- boolean
data-cim-style-root
Section titled “ data-cim-style-root ” -
Use this attribute to "claim" the component tree for exclusive Cimpress UI usage.
- string
UNSAFE_className
Section titled “ UNSAFE_className ” -
Sets the CSS className for the element. Only use as a last resort. Use style props instead.
See styling guide.
- CSSProperties
UNSAFE_style
Section titled “ UNSAFE_style ” -
Sets the CSS style for the element. Only use as a last resort. Use style props instead.
See styling guide.
TableHeaderRow
Section titled “TableHeaderRow”Renders a row within a table header.
- Ref<HTMLTableRowElement>
-
The
reftype for this component.
TableHeaderRowProps
- ReactNode
children *
Section titled “ children * ” -
The header cells that belong to this header row.
- number
rowNumber
Section titled “ rowNumber ” -
The row's position within the full dataset, including headers.
Provide this value if your table presents a subset of rows, such as when using pagination.
This number must be:
- greater than or equal to
1 - greater than the
rowNumberof any previous rows - less than or equal to the
totalRowCountof the parentTable
Use together with
totalRowCounton theTablecomponent. - greater than or equal to
- string
-
The element's unique identifier. See MDN.
- boolean
data-cim-style-root
Section titled “ data-cim-style-root ” -
Use this attribute to "claim" the component tree for exclusive Cimpress UI usage.
- string
UNSAFE_className
Section titled “ UNSAFE_className ” -
Sets the CSS className for the element. Only use as a last resort. Use style props instead.
See styling guide.
- CSSProperties
UNSAFE_style
Section titled “ UNSAFE_style ” -
Sets the CSS style for the element. Only use as a last resort. Use style props instead.
See styling guide.
TableHeaderCell
Section titled “TableHeaderCell”Renders a header cell within a table header row.
- Ref<HTMLTableCellElement>
-
The
reftype for this component.
TableHeaderCellProps
- ReactNode
children *
Section titled “ children * ” -
The contents of the header cell.
- string
columnKey *
Section titled “ columnKey * ” -
A unique identifier for the column that this cell belongs to. Cells that belong to the same column must have the same
columnKey. - number
columnNumber
Section titled “ columnNumber ” -
The position of the column that this cell belongs to within the full dataset.
Provide this value if your table presents a subset of columns, such as when the user toggles column visibility.
This number must be:
- greater than or equal to
1 - greater than the
columnNumberof any previous cells in the current row - less than or equal to the
totalColumnCountof the parentTable
Use together with
totalColumnCounton theTablecomponent. - greater than or equal to
- string | number
columnWidth
Section titled “ columnWidth ” -
The width of the column. Can be any valid value of the
widthCSS property. - ColumnContentAlignment
columnContentAlignment
Section titled “ columnContentAlignment ” - Defaults to 'start' .
Horizontal alignment of cell content within the column.
- TableColumnSortOrder
sortOrder
Section titled “ sortOrder ” -
The current sort order of the column.
- () => void
onSortOrderToggle
Section titled “ onSortOrderToggle ” -
A function called when the column's sort order should change. If not provided, the column will not be sortable.
- ReactNode
iconStart
Section titled “ iconStart ” -
An icon displayed before the header text.
- ReactNode
iconEnd
Section titled “ iconEnd ” -
An icon displayed after the header text.
- string
-
The element's unique identifier. See MDN.
- boolean
data-cim-style-root
Section titled “ data-cim-style-root ” -
Use this attribute to "claim" the component tree for exclusive Cimpress UI usage.
- string
UNSAFE_className
Section titled “ UNSAFE_className ” -
Sets the CSS className for the element. Only use as a last resort. Use style props instead.
See styling guide.
- CSSProperties
UNSAFE_style
Section titled “ UNSAFE_style ” -
Sets the CSS style for the element. Only use as a last resort. Use style props instead.
See styling guide.
TableBody
Section titled “TableBody”Renders a body section within a table.
- Ref<HTMLTableSectionElement>
-
The
reftype for this component.
TableBodyProps
- ReactNode
children *
Section titled “ children * ” -
The rows that belong to this table body.
- string
-
The element's unique identifier. See MDN.
- boolean
data-cim-style-root
Section titled “ data-cim-style-root ” -
Use this attribute to "claim" the component tree for exclusive Cimpress UI usage.
- string
UNSAFE_className
Section titled “ UNSAFE_className ” -
Sets the CSS className for the element. Only use as a last resort. Use style props instead.
See styling guide.
- CSSProperties
UNSAFE_style
Section titled “ UNSAFE_style ” -
Sets the CSS style for the element. Only use as a last resort. Use style props instead.
See styling guide.
TableBodyRow
Section titled “TableBodyRow”Renders a row within a table body.
- Ref<HTMLTableRowElement>
-
The
reftype for this component.
TableBodyRowProps
- ReactNode
children *
Section titled “ children * ” -
The cells that belong to this row.
- number
rowNumber
Section titled “ rowNumber ” -
The row's position within the full dataset, including headers.
Provide this value if your table presents a subset of rows, such as when using pagination.
This number must be:
- greater than or equal to
1 - greater than the
rowNumberof any previous rows - less than or equal to the
totalRowCountof the parentTable
Use together with
totalRowCounton theTablecomponent. - greater than or equal to
- boolean
isSelected
Section titled “ isSelected ” -
Whether the row is selected.
This value will be ignored if
rowSelectionModeon theTablecomponent is set to'none'. - (value?: boolean) => void
onSelectionToggle
Section titled “ onSelectionToggle ” -
A function called when the row's selection state should change.
If called without an argument, you are free to pick the new selection state based on your own logic. If called with an argument, you must set the selection state to the provided value.
- string
-
The element's unique identifier. See MDN.
- boolean
data-cim-style-root
Section titled “ data-cim-style-root ” -
Use this attribute to "claim" the component tree for exclusive Cimpress UI usage.
- string
UNSAFE_className
Section titled “ UNSAFE_className ” -
Sets the CSS className for the element. Only use as a last resort. Use style props instead.
See styling guide.
- CSSProperties
UNSAFE_style
Section titled “ UNSAFE_style ” -
Sets the CSS style for the element. Only use as a last resort. Use style props instead.
See styling guide.
TableBodyCell
Section titled “TableBodyCell”Renders a cell within a table body row.
- Ref<HTMLTableCellElement>
-
The
reftype for this component.
TableBodyCellProps
- ReactNode
children *
Section titled “ children * ” -
The contents of the cell.
- string
columnKey *
Section titled “ columnKey * ” -
A unique identifier for the column that this cell belongs to. Cells that belong to the same column must have the same
columnKey. - string
-
The element's unique identifier. See MDN.
- boolean
data-cim-style-root
Section titled “ data-cim-style-root ” -
Use this attribute to "claim" the component tree for exclusive Cimpress UI usage.
- string
UNSAFE_className
Section titled “ UNSAFE_className ” -
Sets the CSS className for the element. Only use as a last resort. Use style props instead.
See styling guide.
- CSSProperties
UNSAFE_style
Section titled “ UNSAFE_style ” -
Sets the CSS style for the element. Only use as a last resort. Use style props instead.
See styling guide.
TableEmptyState
Section titled “TableEmptyState”Renders an empty state within a table that has no data.
- Ref<HTMLTableCellElement>
-
The
reftype for this component.
TableEmptyStateProps
- string
title *
Section titled “ title * ” -
The title of the empty state.
- string
description *
Section titled “ description * ” -
The description of the empty state.
- ReactNode
action
Section titled “ action ” -
An optional action button displayed within the empty state.
- string
-
The element's unique identifier. See MDN.
- boolean
data-cim-style-root
Section titled “ data-cim-style-root ” -
Use this attribute to "claim" the component tree for exclusive Cimpress UI usage.
- string
UNSAFE_className
Section titled “ UNSAFE_className ” -
Sets the CSS className for the element. Only use as a last resort. Use style props instead.
See styling guide.
- CSSProperties
UNSAFE_style
Section titled “ UNSAFE_style ” -
Sets the CSS style for the element. Only use as a last resort. Use style props instead.
See styling guide.