Skip to content

Table and related components Table Row, Table Header, and Table Cell provide a way to organize and present tabular data or content.

Overview

Table should be used to present tabular data, content, or information to a user.

Usage

  • Display tabular data to a user
  • Organize content by row and column

Sample

Best Practices

Table is an effective way of organizing complex data and content that may have many dimensions. For less complex displays of content collections that do not require row and column relationships, consider List.

Recommendations

It is important to slot Table Rows into the appropriate "table-header" or "table-footer" slot. Doing so ensures assistive technologies can accurately associate cells and their related context. While the "table-header" and "table-footer" slots are not required, Table Rows should be slotted appropriately when used.

Selection modes

Table offers "single" and "multiple" selectionMode values in addition to the default of "none". When enabled, Table displays the current number of selected Table Rows to a user, along with an affordance to clear their selection.

When selectionMode is not "none", the "selection-actions" slot will display alongside the provided selection interface. When used with pageSize, selected rows that are no longer in view will be indicated to a user.

Do use selectionMode when there are associated actions or workflows.
Do use selectionMode when displaying Table Rows that represent selectable entities a user may take action on.
Avoid using selectionMode when there are no associated user interactions.
Avoid using selectionMode with complex rowSpan and colSpan configurations.

Selection displays

When selectionMode is not "none", and selectionDisplay is "top" (the default configuration) - the Table component provides visual affordances for selection count and clearing selection to the user. When in this default display, the selection-actions slot can be useful to populate with related contextual actions.

There are times when this selectionDisplay and associated content slot may not be desirable; when applicable, the selectionDisplay property can be set to "none". This configuration can be useful where the selection count and clear selection affordances are not needed, such as when Tables contain a known and small number of rows, or when an interface should not allow a user to clear a selection. It can also facilitate the creation of alternative or unique selection interfaces for specific use cases.

Pagination

Enable pagination by providing a pageSize. When enabled, Table Rows slotted into the "table-header" or "table-footer" slot will remain visible to a user, while Table Rows slotted into the default slot are paginated.

When used with selectionMode other than "none", selected rows that are no longer in view will be indicated to a user.

Do use pageSize when there may be a large or overwhelming number of Table Rows.
Do use a pageSize of reasonable length.
Avoid using pageSize when there is an expectedly low number of Table Rows.
Avoid using an overly large pageSize value.
Note
The component offers an option for built-in pagination. However, at this time it does not provide lazy loading or virtualization. Calcite hopes to add more methods of providing data to the component in the future.

Accessibility

Keyboard navigation

KeyFunction
Arrow downNavigates to a calcite-table-cell or calcite-table-header in the next calcite-table-row.
Arrow upNavigates to a calcite-table-cell or calcite-table-header in the previous calcite-table-row.
Page UpNavigates to a calcite-table-cell or calcite-table-header in the first visible calcite-table-row.
Page DownNavigates to a calcite-table-cell or calcite-table-header in the last visible calcite-table-row.
HomeNavigates to the first calcite-table-cell or calcite-table-header in the current calcite-table-row.
EndNavigates to the last calcite-table-cell or calcite-table-header in the current calcite-table-row.
Control and HomeNavigates to the first calcite-table-cell or calcite-table-header in the first calcite-table-row.
Control and EndNavigates to the last calcite-table-cell or calcite-table-header in the last calcite-table-row.

API reference

Properties

PropertyAttributeDescriptionTypeDefault
borderedborderedWhen true, displays borders between calcite-table-rows.booleanfalse
captionrequiredcaptionSpecifies an accessible title for the component.string
currentPagecurrent-pageSets/gets the current pagenumber0
groupSeparatorgroup-separatorWhen true, number values are displayed with a group separator corresponding to the language and country format.booleanfalse
interactionModeinteraction-modeWhen "interactive", allows focus and keyboard navigation of table-headers and table-cells. When "static", prevents focus and keyboard navigation of table-headers and table-cells when assistive technologies are not active. Selection affordances and slotted content within table-cells remain focusable.TableInteractionMode"interactive"
layoutlayoutSpecifies the layout of the component.TableLayout"auto"
messageOverridesOverrides individual strings used by the component.Record<string, unknown> | undefined
numberednumberedWhen true, displays the position of the row in numeric form.booleanfalse
numberingSystemnumbering-systemSpecifies the Unicode numeral system used by the component for localization.NumberingSystem | undefined
pageSizepage-sizeSpecifies the page size of the component. When present, renders calcite-pagination.number0
scalescaleSpecifies the component's size.Scale"m"
selectedItemsread-onlySpecifies the component's selected items.TableRow[]
selectionDisplayselection-displayWhen selectionMode is "single" or "multiple", specifies the display of the selection interface. When selectionMode is "none", content slotted in the selection-actions slot will not be displayed.TableSelectionDisplay"top"
selectionModeselection-modeSpecifies the selection mode of the component, where: "multiple" allows any number of selections, "single" allows only one selection, and "none" does not allow any selections.Extract<"none" | "multiple" | "single", SelectionMode>"none"
stripedstripedWhen true, displays striped styling on the component's calcite-table-rows.booleanfalse

Slots

NameDescription
default (unnamed)A slot for adding calcite-table-row elements containing calcite-table-cell and/or calcite-table-header elements.
table-headerA slot for adding calcite-table-row elements containing calcite-table-header elements.
selection-actionsA slot for adding calcite-actions or other elements to display when selectionMode is not "none" and selectionDisplay is not "none".

Styles

NameDescription
--calcite-table-border-colorSpecifies the component's border color.
--calcite-table-corner-radiusSpecifies the component's border radius.
--calcite-table-shadowSpecifies the component's shadow.
--calcite-table-number-cell-background-colorSpecifies the background color of the component's numbered cell.
--calcite-table-number-cell-text-colorSpecifies the text color of the component's numbered cell.
--calcite-table-selection-cell-background-colorWhen selectionMode is "multiple" or "single", specifies the background color of cells containing selection icons.
--calcite-table-selection-cell-background-color-selectedWhen selectionMode is "multiple" or "single", specifies the background color of cells containing selection icons on selected calcite-table-rows.
--calcite-table-selection-cell-icon-colorWhen selectionMode is "multiple" or "single", specifies the icon color of the component's selection icon on calcite-table-rows where selected is false.
--calcite-table-selection-cell-icon-color-selectedWhen selectionMode is "multiple" or "single", specifies the icon color of the component's selection icon on selected calcite-table-rows.
--calcite-table-selection-chip-background-colorWhen selectionMode is "multiple" or "single" and calcite-table-rows are not selected, specifies the background color of the component's selection chip.
--calcite-table-selection-chip-border-colorWhen selectionMode is "multiple" or "single" and calcite-table-rows are not selected, specifies the border color of the component's selection chip.
--calcite-table-selection-chip-corner-radiusWhen selectionMode is "multiple" or "single", specifies the corner radius of the component's selection chip.
--calcite-table-selection-chip-shadowWhen selectionMode is "multiple" or "single", specifies the shadow of the component's selection chip.
--calcite-table-selection-chip-text-colorWhen selectionMode is "multiple" or "single" and calcite-table-rows are not selected, specifies the text color of the component's selection chip.
--calcite-table-selection-chip-background-color-selectedWhen selectionMode is "multiple" or "single" and calcite-table-rows are selected, specifies the background color of the component's selection chip.
--calcite-table-selection-chip-border-color-selectedWhen selectionMode is "multiple" or "single" and calcite-table-rows are selected, specifies the border color of the component's selection chip.
--calcite-table-selection-chip-text-color-selectedWhen selectionMode is "multiple" or "single" and calcite-table-rows are selected, specifies the text color of the component's selection chip.
--calcite-table-selection-out-of-view-chip-background-colorWhen selectionMode is "multiple" or "single", pageSize is set, and calcite-table-rows are selected on non-current pages, specifies the background color of the component's selection out of view chip.
--calcite-table-selection-out-of-view-chip-border-colorWhen selectionMode is "multiple" or "single", pageSize is set, and calcite-table-rows are selected on non-current pages, specifies the border color of the component's selection out of view chip.
--calcite-table-selection-out-of-view-chip-corner-radiusWhen selectionMode is "multiple" or "single", pageSize is set, and calcite-table-rows are selected on non-current pages, specifies the corner radius of the component's selection out of view chip.
--calcite-table-selection-out-of-view-chip-icon-colorWhen selectionMode is "multiple" or "single", pageSize is set, and calcite-table-rows are selected on non-current pages, specifies the icon color of the component's selection out of view chip.
--calcite-table-selection-out-of-view-chip-shadowWhen selectionMode is "multiple" or "single", pageSize is set, and calcite-table-rows are selected on non-current pages, specifies the shadow of the component's selection out of view chip.
--calcite-table-selection-out-of-view-chip-text-colorWhen selectionMode is "multiple" or "single", pageSize is set, and calcite-table-rows are selected on non-current pages, specifies the text color of the component's selection out of view chip.
--calcite-table-selection-dismiss-button-background-color-activeWhen selectionMode is "multiple" or "single" and calcite-table-rows are selected, specifies the background color of the component's selection dismiss chip when active.
--calcite-table-selection-dismiss-button-background-color-hoverWhen selectionMode is "multiple" or "single" and calcite-table-rows are selected, specifies the background color of the component's selection dismiss chip when hovered.
--calcite-table-selection-dismiss-button-background-colorWhen selectionMode is "multiple" or "single" and calcite-table-rows are selected, specifies the background color of the component's selection dismiss chip.
--calcite-table-selection-dismiss-button-border-color-activeWhen selectionMode is "multiple" or "single" and calcite-table-rows are selected, specifies the border color of the component's selection dismiss chip when active.
--calcite-table-selection-dismiss-button-border-color-hoverWhen selectionMode is "multiple" or "single" and calcite-table-rows are selected, specifies the border color of the component's selection dismiss chip when hovered.
--calcite-table-selection-dismiss-button-border-colorWhen selectionMode is "multiple" or "single" and calcite-table-rows are selected, specifies the border color of the component's selection dismiss chip.
--calcite-table-selection-dismiss-button-corner-radiusWhen selectionMode is "multiple" or "single" and calcite-table-rows are selected, specifies the corner radius of the component's selection dismiss chip.
--calcite-table-selection-dismiss-button-shadowWhen selectionMode is "multiple" or "single" and calcite-table-rows are selected, specifies the shadow of the component's selection dismiss chip.
--calcite-table-selection-dismiss-button-text-color-activeWhen selectionMode is "multiple" or "single" and calcite-table-rows are selected, specifies the text color of the component's selection dismiss chip when active.
--calcite-table-selection-dismiss-button-text-color-hoverWhen selectionMode is "multiple" or "single" and calcite-table-rows are selected, specifies the text color of the component's selection dismiss chip when hovered.
--calcite-table-selection-dismiss-button-text-colorWhen selectionMode is "multiple" or "single" and calcite-table-rows are selected, specifies the text color of the component's selection dismiss chip.
--calcite-table-pagination-colorWhen pageSize is set, specifies the component's pagination item color.
--calcite-table-pagination-color-hoverWhen pageSize is set, specifies the component's pagination item color when hovered or selected.
--calcite-table-pagination-color-border-hoverWhen pageSize is set, specifies the component's pagination item bottom border color when hovered.
--calcite-table-pagination-color-border-activeWhen pageSize is set, specifies the component's pagination item bottom border color when selected.
--calcite-table-pagination-background-colorWhen pageSize is set, specifies the component's pagination item background color when active.
--calcite-table-pagination-icon-color-background-hoverWhen pageSize is set, specifies the component's pagination chevron item background color when hovered.

Events

NameDescriptionBehavior
calciteTablePageChangeEmits when the component's page selection changes.bubblescomposed
calciteTableSelectEmits when the component's selected rows change.bubblescomposed

Methods

NameDescriptionSignature
componentOnReadyCreate a promise that resolves once component is fully loaded.componentOnReady(): Promise<this>

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.