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.
Sample
Usage
- Display tabular data to a user
- Organize content by row and column
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" selection 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 selection is not "none", the "selection-actions" slot will display alongside the provided selection interface. When used with page, selected rows that are no longer in view will be indicated to a user.
selectionMode when there are associated actions or workflows.selectionMode when displaying Table Rows that represent selectable entities a user may take action on.selectionMode when there are no associated user interactions.selectionMode with complex rowSpan and colSpan configurations.Selection displays
When selection is not "none", and selection 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 selection and associated content slot may not be desirable; when applicable, the selection 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 page. 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 selection other than "none", selected rows that are no longer in view will be indicated to a user.
pageSize when there may be a large or overwhelming number of Table Rows.pageSize of reasonable length.pageSize when there is an expectedly low number of Table Rows.pageSize value.Accessibility
Keyboard navigation
| Key | Function |
|---|---|
Arrow down | Navigates to a calcite-table-cell or calcite-table-header in the next calcite-table-row. |
Arrow up | Navigates to a calcite-table-cell or calcite-table-header in the previous calcite-table-row. |
Page Up | Navigates to a calcite-table-cell or calcite-table-header in the first visible calcite-table-row. |
Page Down | Navigates to a calcite-table-cell or calcite-table-header in the last visible calcite-table-row. |
Home | Navigates to the first calcite-table-cell or calcite-table-header in the current calcite-table-row. |
End | Navigates to the last calcite-table-cell or calcite-table-header in the current calcite-table-row. |
Control and Home | Navigates to the first calcite-table-cell or calcite-table-header in the first calcite-table-row. |
Control and End | Navigates to the last calcite-table-cell or calcite-table-header in the last calcite-table-row. |
API reference
Properties
| Property | Attribute | Description | Type | Default |
|---|---|---|---|---|
| bordered | bordered | When | boolean | false |
| caption | caption | Specifies an accessible title for the component. | string | |
| currentPage | current-page | Sets/gets the current page | number | 0 |
| groupSeparator | group-separator | When | boolean | false |
| interactionMode | interaction-mode | When | TableInteractionMode | "interactive" |
| layout | layout | Specifies the layout of the component. | TableLayout | "auto" |
| messageOverrides | Overrides individual strings used by the component. | Record<string, unknown> | undefined | ||
| numbered | numbered | When | boolean | false |
| numberingSystem | numbering-system | Specifies the Unicode numeral system used by the component for localization. | NumberingSystem | undefined | |
| pageSize | page-size | Specifies the page size of the component. When present, renders | number | 0 |
| scale | scale | Specifies the component's size. | Scale | "m" |
| selectedItems | Specifies the component's selected items. | TableRow[] | ||
| selectionDisplay | selection-display | When | TableSelectionDisplay | "top" |
| selectionMode | selection-mode | Specifies the selection mode of the component, where:
| Extract<"none" | "multiple" | "single", SelectionMode> | "none" |
| striped | striped | When | boolean | false |
Slots
| Name | Description |
|---|---|
| default (unnamed) | A slot for adding |
| table-header | A slot for adding |
| table-footer | A slot for adding |
| selection-actions | A slot for adding |
Styles
| Name | Description |
|---|---|
| --calcite-table-border-color | Specifies the component's border color. |
| --calcite-table-corner-radius | Specifies the component's border radius. |
| --calcite-table-shadow | Specifies the component's shadow. |
| --calcite-table-number-cell-background-color | Specifies the background color of the component's |
| --calcite-table-number-cell-text-color | Specifies the text color of the component's |
| --calcite-table-selection-cell-background-color | When |
| --calcite-table-selection-cell-background-color-selected | When |
| --calcite-table-selection-cell-icon-color | When |
| --calcite-table-selection-cell-icon-color-selected | When |
| --calcite-table-selection-chip-background-color | When |
| --calcite-table-selection-chip-border-color | When |
| --calcite-table-selection-chip-corner-radius | When |
| --calcite-table-selection-chip-shadow | When |
| --calcite-table-selection-chip-text-color | When |
| --calcite-table-selection-chip-background-color-selected | When |
| --calcite-table-selection-chip-border-color-selected | When |
| --calcite-table-selection-chip-text-color-selected | When |
| --calcite-table-selection-out-of-view-chip-background-color | When |
| --calcite-table-selection-out-of-view-chip-border-color | When |
| --calcite-table-selection-out-of-view-chip-corner-radius | When |
| --calcite-table-selection-out-of-view-chip-icon-color | When |
| --calcite-table-selection-out-of-view-chip-shadow | When |
| --calcite-table-selection-out-of-view-chip-text-color | When |
| --calcite-table-selection-dismiss-button-background-color-active | When |
| --calcite-table-selection-dismiss-button-background-color-hover | When |
| --calcite-table-selection-dismiss-button-background-color | When |
| --calcite-table-selection-dismiss-button-border-color-active | When |
| --calcite-table-selection-dismiss-button-border-color-hover | When |
| --calcite-table-selection-dismiss-button-border-color | When |
| --calcite-table-selection-dismiss-button-corner-radius | When |
| --calcite-table-selection-dismiss-button-shadow | When |
| --calcite-table-selection-dismiss-button-text-color-active | When |
| --calcite-table-selection-dismiss-button-text-color-hover | When |
| --calcite-table-selection-dismiss-button-text-color | When |
| --calcite-table-pagination-color | When |
| --calcite-table-pagination-color-hover | When |
| --calcite-table-pagination-color-border-hover | When |
| --calcite-table-pagination-color-border-active | When |
| --calcite-table-pagination-background-color | When |
| --calcite-table-pagination-icon-color-background-hover | When |
Events
| Name | Description | Behavior |
|---|---|---|
| calciteTablePageChange | Emits when the component's page selection changes. | |
| calciteTableSelect | Emits when the component's selected rows change. |
Methods
| Name | Description | Signature |
|---|---|---|
| componentOnReady | Creates a promise that resolves once the component is fully loaded. | componentOnReady(): Promise<this> |