Intelligence Community Design System ICDS Get started Accessibility Styles Components Patterns Community
Show navigation section

Data table

Guidance Code Accessibility

Component demo

Interactive example

<ic-data-tablecaption="Basic Table"></ic-data-table>

Data table details

Props

All components also accept native properties supported by the DOM, such asclassName and style .

Name Description Default
Property caption
Attribute caption

The title for the table only visible to screen readers.

Required type: string
Property columns

The column headers for the table.

Required type: IcDataTableColumnObject[] - { key: string; title: string; dataType: IcDataTableColumnDataTypes; columnAlignment?: IcDataTableAlignmentOptions; columnWidth?: string | IcDataTableColumnWidthTypes; textWrap?: boolean; cellAlignment?: string; emphasis?: string; colspan?: number; icon?: { icon: string; onAllCells?: boolean; hideOnHeader?: boolean; }; excludeColumnFromSort?: boolean; hidden?: boolean; disableAutoSort?: boolean; }
Property columnHeaderTruncation
Attribute column-header-truncation

Determines whether the column header should be truncated and display a tooltip. Default isfalse .

type: boolean
false
Property data

The row content for the table.

type: IcDataTableDataType[] - IcDataTableDataType[] | undefined
Property density
Attribute density

Set the density of the table including font and padding.

type: IcDataTableDensityOptions - "default" | "dense" | "spacious"
"default"
Property disableAutoSort
Attribute disable-auto-sort

Iftrue , the built in sort functionality will be disabled. For example, if rows will already be sorted from an external source.

type: boolean - boolean | undefined
false
Property embedded
Attribute embedded

Applies a border to the table container.

type: boolean
false
Property globalRowHeight
Attribute global-row-height

Sets the row height on all rows in the table that aren't set using thevariableRowHeight method.

type: IcDataTableRowHeights - "auto" | number
"auto"
Property height
Attribute height

Sets the table height. Can be set toauto or a specific value inpx ,rem , or% .

type: string - string | undefined
Property hideColumnHeaders
Attribute hide-column-headers

Iftrue , column headers will not be visible.

type: boolean - boolean | undefined
false
Property loading
Attribute loading

When set totrue , the full table will show a loading state, featuring a radial indicator.

type: boolean
false
Property loadingOptions

Sets the props for the circular loading indicator used in the loading state.

type: { description?: string; label?: string; labelDuration?: number; max?: number; min?: number; progress?: number; monochrome?: boolean; overlay?: boolean; } - undefined | { description?: string | undefined; label?: string | undefined; labelDuration?: number | undefined; max?: number | undefined; min?: number | undefined; progress?: number | undefined; monochrome?: boolean | undefined; overlay?: boolean | undefined; }
Property maxWidth
Attribute max-width

Sets the maximum width of the data table. Can be set inpx ,rem , or% .

type: string - string | undefined
Property minWidth
Attribute min-width

Sets the minimum width of the data table. Can be set inpx ,rem , or% .

type: string - string | undefined
Property minimumLoadingDisplayDuration
Attribute minimum-loading-display-duration

The minimum amount of time theloading state displays for before showing the data. Used to prevent flashing in the component.

type: number
1000
Property paginationBarOptions

Sets the props for the built-in pagination bar. If thepagination-bar slot is used then this prop is ignored.

type: IcPaginationBarOptions - export interface IcPaginationBarOptions { alignment?: IcPaginationAlignmentOptions; hideAllFromItemsPerPage?: boolean; hideRangeLabel?: boolean; itemLabel?: string; itemsPerPageOptions?: { label: string; value: string }[]; monochrome?: boolean; pageLabel?: string; rangeLabelType?: IcPaginationLabelTypes; selectedItemsPerPage?: number; selectItemsPerPageOnEnter?: boolean; setToFirstPageOnPaginationChange?: boolean; showGoToPageControl?: boolean; showItemsPerPageControl?: boolean; theme?: IcThemeMode; type?: IcPaginationTypes; }
{ alignment: "right", hideAllFromItemsPerPage: false, hideRangeLabel: false, itemLabel: "Item", itemsPerPageOptions: [ { label: "10", value: "10" }, { label: "25", value: "25" }, { label: "50", value: "50" }, ], monochrome: false, pageLabel: "Page", rangeLabelType: "page", selectedItemsPerPage: 10, selectItemsPerPageOnEnter: true, setToFirstPageOnPaginationChange: false, showGoToPageControl: true, showItemsPerPageControl: true, type: "simple", }
Property rowSelection
Attribute row-selection

Iftrue , a checkbox column will be displayed to the left of the table which allows multiple rows to be selected.

type: boolean
false
Property showPagination
Attribute show-pagination

Iftrue , adds a pagination bar to the bottom of the table.

type: boolean - boolean | undefined
false
Property sortOptions

Sets the order columns will be sorted in and allows for 'default' sorts to be added.

type: { sortOrders: IcDataTableSortOrderOptions[]; defaultColumn?: string; } - { sortOrders: IcDataTableSortOrderOptions[]; defaultColumn?: string | undefined; }
{ sortOrders: ["unsorted", "ascending", "descending"], defaultColumn: "", }
Property sortable
Attribute sortable

Iftrue , allows table columns to be sorted using applied sort buttons.

type: boolean - boolean | undefined
false
Property stickyColumnHeaders
Attribute sticky-column-headers

Iftrue , column headers will remain at the top of the table when scrolling vertically.

type: boolean
false
Property stickyRowHeaders
Attribute sticky-row-headers

Iftrue , row headers will remain to the left when scrolling horizontally.

type: boolean
false
Property tableLayout
Attribute table-layout

Sets the layout of the table

type: "fixed" | "auto" - "auto" | "fixed" | undefined
"fixed"
Property theme
Attribute theme

Sets the theme color to the dark or light theme color. "inherit" will set the color based on the system settings or ic-theme component.

type: IcThemeMode - "dark" | "inherit" | "light" | undefined
"inherit"
Property truncationPattern
Attribute truncation-pattern

Sets the method used to truncate long text in cells where textWrap isfalse . Thetooltip truncation pattern allows the overflowing text to be seen in a tooltip. Theshow-hide truncation pattern allows the overflowing text to be shown and hidden using the ic-typography "See more"/"See less" buttons.

type: IcDataTableTruncationTypes - "show-hide" | "tooltip" | undefined
Property updating
Attribute updating

Iftrue , the table displays a linear loading indicator below the header row to indicate an updating state.

type: boolean
false
Property updatingOptions

Sets the props for the linear loading indicator used in the updating state.

type: { description?: string; max?: number; min?: number; progress?: number; monochrome?: boolean; } - undefined | { description?: string | undefined; max?: number | undefined; min?: number | undefined; progress?: number | undefined; monochrome?: boolean | undefined; }
Property variableRowHeight

Allows for custom setting of row heights on individual rows based on an individual value from thedata prop and the row index. If the function returnsnull , that row's height will be set to theglobalRowHeight property.

type: (params: { [key: string]: any; index: number; }) => IcDataTableRowHeights | null - ((params: { [key: string]: any; index: number; }) => IcDataTableRowHeights | null) | undefined
Property width
Attribute width

Sets the table width. Can be set toauto or a specific value inpx ,rem , or% .

type: string - string | undefined
Property caption
Attribute caption

The title for the table only visible to screen readers.

Required type: string
Property columns

The column headers for the table.

Required type: IcDataTableColumnObject[] - { key: string; title: string; dataType: IcDataTableColumnDataTypes; columnAlignment?: IcDataTableAlignmentOptions; columnWidth?: string | IcDataTableColumnWidthTypes; textWrap?: boolean; cellAlignment?: string; emphasis?: string; colspan?: number; icon?: { icon: string; onAllCells?: boolean; hideOnHeader?: boolean; }; excludeColumnFromSort?: boolean; hidden?: boolean; disableAutoSort?: boolean; }
Property columnHeaderTruncation
Attribute column-header-truncation

Determines whether the column header should be truncated and display a tooltip. Default isfalse .

type: boolean
Default: false
Property data

The row content for the table.

type: IcDataTableDataType[] - IcDataTableDataType[] | undefined
Property density
Attribute density

Set the density of the table including font and padding.

type: IcDataTableDensityOptions - "default" | "dense" | "spacious"
Default: "default"
Property disableAutoSort
Attribute disable-auto-sort

Iftrue , the built in sort functionality will be disabled. For example, if rows will already be sorted from an external source.

type: boolean - boolean | undefined
Default: false
Property embedded
Attribute embedded

Applies a border to the table container.

type: boolean
Default: false
Property globalRowHeight
Attribute global-row-height

Sets the row height on all rows in the table that aren't set using thevariableRowHeight method.

type: IcDataTableRowHeights - "auto" | number
Default: "auto"
Property height
Attribute height

Sets the table height. Can be set toauto or a specific value inpx ,rem , or% .

type: string - string | undefined
Property hideColumnHeaders
Attribute hide-column-headers

Iftrue , column headers will not be visible.

type: boolean - boolean | undefined
Default: false
Property loading
Attribute loading

When set totrue , the full table will show a loading state, featuring a radial indicator.

type: boolean
Default: false
Property loadingOptions

Sets the props for the circular loading indicator used in the loading state.

type: { description?: string; label?: string; labelDuration?: number; max?: number; min?: number; progress?: number; monochrome?: boolean; overlay?: boolean; } - undefined | { description?: string | undefined; label?: string | undefined; labelDuration?: number | undefined; max?: number | undefined; min?: number | undefined; progress?: number | undefined; monochrome?: boolean | undefined; overlay?: boolean | undefined; }
Property maxWidth
Attribute max-width

Sets the maximum width of the data table. Can be set inpx ,rem , or% .

type: string - string | undefined
Property minWidth
Attribute min-width

Sets the minimum width of the data table. Can be set inpx ,rem , or% .

type: string - string | undefined
Property minimumLoadingDisplayDuration
Attribute minimum-loading-display-duration

The minimum amount of time theloading state displays for before showing the data. Used to prevent flashing in the component.

type: number
Default: 1000
Property paginationBarOptions

Sets the props for the built-in pagination bar. If thepagination-bar slot is used then this prop is ignored.

type: IcPaginationBarOptions - export interface IcPaginationBarOptions { alignment?: IcPaginationAlignmentOptions; hideAllFromItemsPerPage?: boolean; hideRangeLabel?: boolean; itemLabel?: string; itemsPerPageOptions?: { label: string; value: string }[]; monochrome?: boolean; pageLabel?: string; rangeLabelType?: IcPaginationLabelTypes; selectedItemsPerPage?: number; selectItemsPerPageOnEnter?: boolean; setToFirstPageOnPaginationChange?: boolean; showGoToPageControl?: boolean; showItemsPerPageControl?: boolean; theme?: IcThemeMode; type?: IcPaginationTypes; }
Default: { alignment: "right", hideAllFromItemsPerPage: false, hideRangeLabel: false, itemLabel: "Item", itemsPerPageOptions: [ { label: "10", value: "10" }, { label: "25", value: "25" }, { label: "50", value: "50" }, ], monochrome: false, pageLabel: "Page", rangeLabelType: "page", selectedItemsPerPage: 10, selectItemsPerPageOnEnter: true, setToFirstPageOnPaginationChange: false, showGoToPageControl: true, showItemsPerPageControl: true, type: "simple", }
Property rowSelection
Attribute row-selection

Iftrue , a checkbox column will be displayed to the left of the table which allows multiple rows to be selected.

type: boolean
Default: false
Property showPagination
Attribute show-pagination

Iftrue , adds a pagination bar to the bottom of the table.

type: boolean - boolean | undefined
Default: false
Property sortOptions

Sets the order columns will be sorted in and allows for 'default' sorts to be added.

type: { sortOrders: IcDataTableSortOrderOptions[]; defaultColumn?: string; } - { sortOrders: IcDataTableSortOrderOptions[]; defaultColumn?: string | undefined; }
Default: { sortOrders: ["unsorted", "ascending", "descending"], defaultColumn: "", }
Property sortable
Attribute sortable

Iftrue , allows table columns to be sorted using applied sort buttons.

type: boolean - boolean | undefined
Default: false
Property stickyColumnHeaders
Attribute sticky-column-headers

Iftrue , column headers will remain at the top of the table when scrolling vertically.

type: boolean
Default: false
Property stickyRowHeaders
Attribute sticky-row-headers

Iftrue , row headers will remain to the left when scrolling horizontally.

type: boolean
Default: false
Property tableLayout
Attribute table-layout

Sets the layout of the table

type: "fixed" | "auto" - "auto" | "fixed" | undefined
Default: "fixed"
Property theme
Attribute theme

Sets the theme color to the dark or light theme color. "inherit" will set the color based on the system settings or ic-theme component.

type: IcThemeMode - "dark" | "inherit" | "light" | undefined
Default: "inherit"
Property truncationPattern
Attribute truncation-pattern

Sets the method used to truncate long text in cells where textWrap isfalse . Thetooltip truncation pattern allows the overflowing text to be seen in a tooltip. Theshow-hide truncation pattern allows the overflowing text to be shown and hidden using the ic-typography "See more"/"See less" buttons.

type: IcDataTableTruncationTypes - "show-hide" | "tooltip" | undefined
Property updating
Attribute updating

Iftrue , the table displays a linear loading indicator below the header row to indicate an updating state.

type: boolean
Default: false
Property updatingOptions

Sets the props for the linear loading indicator used in the updating state.

type: { description?: string; max?: number; min?: number; progress?: number; monochrome?: boolean; } - undefined | { description?: string | undefined; max?: number | undefined; min?: number | undefined; progress?: number | undefined; monochrome?: boolean | undefined; }
Property variableRowHeight

Allows for custom setting of row heights on individual rows based on an individual value from thedata prop and the row index. If the function returnsnull , that row's height will be set to theglobalRowHeight property.

type: (params: { [key: string]: any; index: number; }) => IcDataTableRowHeights | null - ((params: { [key: string]: any; index: number; }) => IcDataTableRowHeights | null) | undefined
Property width
Attribute width

Sets the table width. Can be set toauto or a specific value inpx ,rem , or% .

type: string - string | undefined

Slots

A slot allows for any type of element or markup to be passed into and rendered within a web component. This creates more flexibility than using a prop which must take a specific type of data.

Content can be slotted into a component by adding it as a top-level child of the component.

Slots can have a name to identify them. These specify which slot the content will be inserted into, and therefore where it will be rendered and how it will be used within the component. The name of the slot to be used can be specified by passing it via a slot attribute on the slotted content.

Read more about slots .


Name Description
Slot empty-state
Content is slotted below the table header when there is no data and the table is not loading.
Slot pagination-bar
A custom ic-pagination-bar can be slotted below the data to provide enhanced control over how the data is interacted with when being fetched externally.
Slot title-bar
A custom ic-data-table-title-bar can be slotted above the column headers to display additional information about the table.
Slot {COLUMN_KEY}-column-icon
The icon slot for a column header.
Slot {COLUMN_KEY}-{ROW_INDEX}[-icon]
Each cell should have its own slot, named using the column tag and the row index, allowing for custom elements to be displayed. Include `-icon` at the end for that cell's icon slot.
Slot empty-state
Content is slotted below the table header when there is no data and the table is not loading.
Slot pagination-bar
A custom ic-pagination-bar can be slotted below the data to provide enhanced control over how the data is interacted with when being fetched externally.
Slot title-bar
A custom ic-data-table-title-bar can be slotted above the column headers to display additional information about the table.
Slot {COLUMN_KEY}-column-icon
The icon slot for a column header.
Slot {COLUMN_KEY}-{ROW_INDEX}[-icon]
Each cell should have its own slot, named using the column tag and the row index, allowing for custom elements to be displayed. Include `-icon` at the end for that cell's icon slot.

Events

All components also accept native events supported by the DOM, such as onClick and onKeyDown .

Name Description Signature
Web component icColumnsLoaded
React onIcColumnsLoaded
Emitted when the columns have finished loading after being updated or initially rendered.
void
Web component icDataLoaded
React onIcDataLoaded
Emitted when the data has finished loading after being updated or initially rendered.
void
Web component icRowHeightChange
React onIcRowHeightChange
Emitted when the `globalRowHeight` or `variableRowHeight` properties change in the data table.
void
Web component icSelectAllRows
React onIcSelectAllRows
Emitted when all rows are selected or deselected in the data table via the "select all" checkbox.
IcDataTableDataType[]
Web component icSelectedRowChange
React onIcSelectedRowChange
Emitted when the selected row changes in the data table.
{ row: IcDataTableDataType | null; selectedRows: IcDataTableDataType[]; }
Web component icSortChange
React onIcSortChange
Emitted when a column sort button is clicked.
IcSortEventDetail
Web component icColumnsLoaded
React onIcColumnsLoaded
Emitted when the columns have finished loading after being updated or initially rendered.
void
Web component icDataLoaded
React onIcDataLoaded
Emitted when the data has finished loading after being updated or initially rendered.
void
Web component icRowHeightChange
React onIcRowHeightChange
Emitted when the `globalRowHeight` or `variableRowHeight` properties change in the data table.
void
Web component icSelectAllRows
React onIcSelectAllRows
Emitted when all rows are selected or deselected in the data table via the "select all" checkbox.
IcDataTableDataType[]
Web component icSelectedRowChange
React onIcSelectedRowChange
Emitted when the selected row changes in the data table.
{ row: IcDataTableDataType | null; selectedRows: IcDataTableDataType[]; }
Web component icSortChange
React onIcSortChange
Emitted when a column sort button is clicked.
IcSortEventDetail

Methods

Name Description Signature
Method resetRowHeights
Resets the `globalRowHeight` prop to number or auto and sets the `variableRowHeight` prop to `null`.
resetRowHeights(rowHeight?: number | "auto") => Promise<void>
Method resetRowHeights
Resets the `globalRowHeight` prop to number or auto and sets the `variableRowHeight` prop to `null`.
resetRowHeights(rowHeight?: number | "auto") => Promise<void>

Variants

Embedded

Theembedded prop adds a border around the table so it can be added as a standalone table and is not required to stretch the full width of its parent container.

Interactive example

<ic-data-tablecaption="Embedded Table"embedded="true"></ic-data-table>

Dense

Thedensity variant provides three different styles for the data table:

  • dense reduces the padding and font size of the table cells to give the data a more dense style.

  • default provides a padding of8px which is the default spacing. This variant is seen in the component demo .

  • spacious gives the data table a more spacious look and feel by increasing the vertical padding as well as the font size.

Interactive example

<ic-data-tablecaption="Dense Table"density="dense"></ic-data-table>

Spacious

Interactive example

<ic-data-tablecaption="Spacious Table"density="spacious"></ic-data-table>

Sticky column headers

When a height for the data table is set, the scroll bar will appear to the right. However, by default, the column headers will move up and out of view making it difficult to understand what the data means.

This can be mitigated by using thestickyColumnHeaders prop which takes a boolean. This can be toggled within the example below.

Interactive example

Stick Header Unstick Header
<ic-data-table
caption="Sticky header Table"
sticky-column-headers="true"
></ic-data-table>

Row headers

Row headers allow headings to be added to individual rows and styles them as column headings. The column collection includes an additionalheader key which aligns with the row headers. The structure of theheader column is the same as the columns (i.e.key ,title ,dataType ).

The data array includes an additionalheader key within therowOptions which takes a string intended to be the title of the row header.

Interactive example

<ic-data-tablecaption="Row headers"></ic-data-table>

Sortable

Setsortable totrue to set the sort functionality on all columns. Sorting can be set tounsorted ,ascending anddescending by pressing the sort buttons next to the column heading.

SetdisableAutoSort to enable external sorting functionality. Alternatively, setdisableAutoSort within the column object to have it apply only to certain columns that may require special custom sorting.

Interactive example

<ic-data-tablecaption="Sort"sortable="true"></ic-data-table>

Sort options

It is possible to change the sort options for the sort buttons. ThesortOptions prop takes an object withsortOrders anddefaultColumn .sortOrders allows the sort order to be amended as well as allowing sort types to be removed - such as changing the order todescending andunsorted , and removingascending .defaultColumn sets which column is ordered by default. This is set by putting the column key as thedefaultColumn value.

Interactive example

<ic-data-tablecaption="Sort Options"sortable="true"></ic-data-table>

Exclude columns from sort

AddingexcludeColumnFromSort: true to the column object excludes that column from displaying the sort button.

Interactive example

<ic-data-tablecaption="Exclude columns from sort"sortable="true"></ic-data-table>

Pagination

Pagination allows large data sets to be split into pages in order to make the data easier to digest. SettingshowPagination totrue will add the ic-pagination component to the bottom of the table. There are several sub-components within the pagination which are set via thepaginationBarOptions prop:

  • itemsPerPage allows customisation of the number of items on each page. This requires a collection withlabel andvalue key pairs.

  • showItemsPerPageControl shows or hides theitemsPerPage component usingtrue orfalse .

  • showGoToPageControl displays controls which allows jumping between pages in a non-linear approach.

Interactive example

<ic-data-tablecaption="Pagination"show-pagination="true"></ic-data-table>

Slotted pagination

There may be scenarios when pagination and data fetching is done using a backend API.

To enable this behaviour, thepagination-bar slot can be utilised to provide a customic-pagination-bar component, allowing the user to have more control over how their data is displayed and interacted with.

Interactive example

<ic-data-tablecaption="Slotted pagination bar">
<ic-pagination-barslot="pagination-bar"show-items-per-page-control="true"></ic-pagination-bar>
</ic-data-table>

Pagination – with setToFirstPageOnPaginationChange

Interactive example

<ic-data-tablecaption="Pagination with page reset on items per page change"show-pagination="true"></ic-data-table>

Column overrides

There may be a requirement to style a column differently to the rest of the data to add emphasis. To do this, addcolumnAlignment to the column, as demonstrated with the 'First name' column below.columnAlignment takes an object which sets thehorizontal andvertical property:

  • horizontal acceptsleft ,right orcenter .

  • vertical acceptstop ,middle ,bottom .

emphasis can be added to the column by settinghigh orlow .

Interactive example

<ic-data-tablecaption="Column Overrides"></ic-data-table>

Row overrides

Row overrides allow styling to be applied at a row level and is set within therowOptions object. The following row overrides options apply:

  • rowAlignment acceptsleft ,right andcenter .

  • emphasis acceptshigh orlow .

  • textWrap acceptstrue orfalse .

Interactive example

<ic-data-tablecaption="Row Overrides"></ic-data-table>

Cell overrides

Cell overrides allow styling to be applied at a cell level. The cell which requires an override accepts an object which requiresdata and can containcellAlignment and/oremphasis :

  • data is the cell value.

  • emphasis acceptshigh orlow .

  • cellAlignment accepts an object with the following key pairs:

    • horizontal acceptsleft ,right orcenter .

    • vertical acceptstop ,middle ,bottom .

Interactive example

<ic-data-tablecaption="Cell Overrides"></ic-data-table>

Default Empty State

When the table receives no data (eithernull or an empty array), it will automatically show anic-empty-state below the headers.

Interactive example

<ic-data-tablecaption="Default Empty State"></ic-data-table>

Slotted Empty State

You can customise your own ic-empty-state component and slot it into the data table using theempty-state slot, to reflect different scenarios.

Interactive example

Retry
<ic-data-tableid="data-table"caption="Slotted Empty State">
<ic-empty-state
aligned="left"
heading="Data source error"
body="Error loading new data"
>
<ic-buttonslot="actions">Retry</ic-button>
</ic-empty-state>
</ic-data-table>

Loading state

When a user wants to fetch their data asynchronously, aloading prop can be set totrue , which then renders a circular variant of the ic-loading-indicator .

The loading indicator can be customised using theloadingOptions prop:

  • description sets the aria-label of the component.

  • label sets the visual message.

  • labelDuration is the number of milliseconds before the label changes.

  • overlay renders a dark overlay over the previous data set while new data is loaded.

If it needs to be determinate, usemax ,min andprogress .

Interactive example

<ic-data-tableid="data-table"caption="Loading State"></ic-data-table>

Updating state

If data in the table has changed, anupdating prop has been supplied to show a linearic-loading-indicator just above the data rows.

This prop is also accompanied by anupdatingOptions prop, which contains similar options toloadingOptions , minuslabel andlabelDuration .

Interactive example

<ic-data-tableid="data-table"caption="Updating State"></ic-data-table>

Custom HTML elements can be slotted or passed via thedata prop to display in certain cells. When using the slotted method, the slot name follows the format of{COLUMN_TAG}-{ROW_INDEX} .

Interactive example

Delete Delete Delete
<ic-data-tablecaption="Links and Elements in data"></ic-data-table>

Custom icons

Custom icons can be added to cells, columns and headers in the data table. To add it to headers, set the icon via thecolumns prop:

icon: {
 icon: //ICON_STRING_GOES_HERE,
 onAllCells: //Boolean to determine whether column header icon should be replicated on all cells in the column,
 hideOnHeader: //Boolean for whether this icon should only be shown on cells and not on the header,
}

To add icons to individual cells, they can be added through thedata prop, in a similar method to overriding the cell. Cell icons take priority over theonAllCells prop, meaning specific cells can be made to stand out.

Both cells and headers can also have icons slotted in. Cells use the slot format:{COLUMN_KEY}-{ROW_INDEX}-icon , and headers use the format:{COLUMN_KEY}-column-icon . Slotted icons take priority over icons inserted via thecolumns anddata props.

Interactive example

<ic-data-tableid="data-table"caption="Custom Icons">
<svg
slot="age-column-icon"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
>
<path
d="M12 6C13.11 6 14 5.1 14 4C14 3.62 13.9 3.27 13.71 2.97L12 0L10.29 2.97C10.1 3.27 10 3.62 10 4C10 5.1 10.9 6 12 6M18 9H13V7H11V9H6C4.34 9 3 10.34 3 12V21C3 21.55 3.45 22 4 22H20C20.55 22 21 21.55 21 21V12C21 10.34 19.66 9 18 9M19 20H5V17C5.9 17 6.76 16.63 7.4 16L8.5 14.92L9.56 16C10.87 17.3 13.15 17.29 14.45 16L15.53 14.92L16.6 16C17.24 16.63 18.1 17 19 17V20M19 15.5C18.5 15.5 18 15.3 17.65 14.93L15.5 12.8L13.38 14.93C12.64 15.67 11.35 15.67 10.61 14.93L8.5 12.8L6.34 14.93C6 15.29 5.5 15.5 5 15.5V12C5 11.45 5.45 11 6 11H18C18.55 11 19 11.45 19 12V15.5Z"
/>
</svg>
</ic-data-table>

Custom row heights

A data table can have its rows use custom heights, to help display more data per row. This involves using theglobalRowHeight prop, which applies this custom height to all rows.

For a more granular approach,variableRowHeight exists. This is passed through the data object for each row of data, as well as that row'sindex . Using these properties, you can write a custom function that will return a number for that row's height based on your criteria. Returningnull from this function means that the row will use theglobalRowHeight property value.

NOTE: If the data table uses thedensity prop, then your custom value will be scaled depending on the density, in order to keep content readable as the text size changes:

  • Dense = 80% ofglobalRowHeight orvariableRowHeight .

  • Spacious = 120% ofglobalRowHeight orvariableRowHeight .

For example, ifglobalRowHeight = 100, a dense table will set the height to be 80 .

NOTE: If a cell has a description (see Description and icons within cells ), then the row height for that individual row will be increased by the description height in order to fully display it.

For example, ifglobalRowHeight = 100 and a cell has a description with a height of 20, then the row height for that cell's row will be set to 120 .

To quickly reset all row heights to the default, you can run theresetRowHeights method.

If you would rather let the row calculate its own height based on its content, either setglobalRowHeight toauto , or returnauto fromvariableRowHeight .

Interactive example

<ic-data-tableid="data-table"caption="Custom Row Heights"></ic-data-table>

Custom title bar

To add additional information about the data held in your data table, you can use thetitle-bar slot to add anic-data-table-title-bar , which will appear above the column headers.

The title bar can have a description and metadata added, to provide supporting information to display some context about the data to the user. Primary and custom action slots also exist to allow for actions to be performed that are related to the data, which can be prominently displayed.

Theic-data-table-title-bar has a built-in density selector, which allows a user to quickly change the size and padding of cells to make it more readable. This can also be hidden if preferred.

Interactive example

Add new order

A log kept of all coffee orders to refer back to.

<ic-data-tableid="data-table"caption="Coffee Orders">
<ic-data-table-title-bar
slot="title-bar"
description="A list of all coffee orders in the last year."
metadata="3 items | Updated: 20/03/25"
>
<ic-buttonslot="primary-action">Add new order</ic-button>
<ic-buttonslot="custom-actions"variant="icon"aria-label="Coffee 1">
<svg
xmlns="http://www.w3.org/2000/svg"
height="24"
viewBox="0 -960 960 960"
width="24"
>
<path
d="M180-120q-24 0-42-18t-18-42v-600q0-24 18-42t42-18h600q24 0 42 18t18 42v600q0 24-18 42t-42 18H180Zm0-60h600v-600H180v600Zm56-97h489L578-473 446-302l-93-127-117 152Zm-56 97v-600 600Z"
/>
</svg>
</ic-button>
<ic-buttonslot="custom-actions"variant="icon"aria-label="Coffee 2">
<svg
xmlns="http://www.w3.org/2000/svg"
height="24"
viewBox="0 -960 960 960"
width="24"
>
<path
d="M180-120q-24 0-42-18t-18-42v-600q0-24 18-42t42-18h600q24 0 42 18t18 42v600q0 24-18 42t-42 18H180Zm0-60h600v-600H180v600Zm56-97h489L578-473 446-302l-93-127-117 152Zm-56 97v-600 600Z"
/>
</svg>
</ic-button>
<ic-typographyslot="description"variant="body">
<p>
A log kept of all{' '}
<ic-linkhref="#">coffee orders</ic-link> to refer back to.
</p>
</ic-typography>
</ic-data-table-title-bar>
</ic-data-table>

Truncation - tooltip

When a row is given a set height, and has content that no longer fits into the cell area, the content becomes truncated. There are two types of truncation:

  • tooltip : Adds a line-clamp to the cell and displays the message in a tooltip.

  • show-hide : Adds aSee more/See less button underneath the cell text, allowing the user to display the full content should they wish.

These values are set using thetruncationPattern prop.

By default,globalRowHeight is set toauto . If thetruncationPattern prop is set totooltip orshow-hide whileglobalRowHeight isauto , the data will not appear truncated due to the row height being set to the height of the tallest data row.

To see the data truncated, theglobalRowHeight orvariableRowHeight needs to be explicitly set to a height which is shorter than data which has the most lines.

NOTE: truncationPattern only applies to a cell's main data value. If a cell has a description (see Description and icons within cells ) then this will not be truncated and will still be visible beyond the truncation.

Interactive example

<ic-data-tablecaption="Data table truncation - tooltip"truncation-pattern="tooltip"></ic-data-table>

Truncation - show/hide

Interactive example

<ic-data-tablecaption="Data table truncation - show/hide"truncation-pattern="show-hide"></ic-data-table>

Text wrap

Text can be set to wrap in a particular column, row or cell. Any column, row or cell that text wrap is applied to will ignore the custom height if the custom height is too small and the full content will be shown.

To set text to wrap in a column, addtextWrap: true as a key value:

const column = [
  { key: "name", title: "Name", dataType: "string", textWrap: true },
  ...
]

To set text to wrap in a row, addrowOptions: { textWrap: true } to an object within the data array:

const data = [
  {
    name: "Tim Rayes",
    age: 41,
    department: "Sales and Marketing",
    employeeNumber: 3,
    jobTitle:
      "Regional Sales and Marketing Strategy Director (Europe, the Middle East, and Africa)",
    rowOptions: {
      textWrap: true
    }
  },
  ...
]

To set text wrap in a cell, addtextWrap to a data key within an object:

const data = [
  {
    name: {
      data: "Tim Rayes",
      textWrap: true
    },
    age: 41,
    department: "Sales and Marketing",
    employeeNumber: 3,
    jobTitle:
      "Regional Sales and Marketing Strategy Director (Europe, the Middle East, and Africa)",
  },
  ...
]

Interactive example

<ic-data-tablecaption="Data table text wrap"></ic-data-table>

Columns widths and table sizing

The dimensions of the data table can be set using thewidth andheight attributes. The attribute accepts dimensions inpx ,% ,rem andauto .

By default, the width is set to100% so the table spans across the viewport or parent container.

To set the column widths, thecolumnWidth property should be added to the relevant column within the column array.

The table layout attribute is vital to how the table resizing and column widths behave.

By default, the table layout is set tofixed . If no column width is set, the columns widths will be equally set within the viewport or parent container.

A table with afixed layout will force the table column widths to take precedence over the data with the table cells.

For the column widths to be dictated by the content inside, set thetableLayout prop toauto and set the tablewidth toauto .

To set the min and max width of a table cell, set thetableLayout prop toauto and set aminWidth ormaxWidth value incolumnWidth .minWidth andmaxWidth accept dimensions inpx ,% ,rem .

Interactive example

<ic-data-tablecaption="Columns widths and table sizing"table-layout="auto"width="800px"></ic-data-table>

Description and icons within cells

Descriptions and icons can be included in the cells by proving adescription field in the data. This will populate the cell with an icon (if provided) and a text string underneath the cell data. This can be applied to any cell.

You can provide adescription object with or without an icon:

// With an icon
firstName: {
  data: "Joe",
  description: {
    data: "The name of Joe",
    icon: '<svg xmlns="http://www.w3.org/2000/svg" height="20" viewBox="0 -960 960 960" width="20"><path d="M180-120q-24 0-42-18t-18-42v-600q0-24 18-42t42-18h600q24 0 42 18t18 42v600q0 24-18 42t-42 18H180Zm0-60h600v-600H180v600Zm56-97h489L578-473 446-302l-93-127-117 152Zm-56 97v-600 600Z"/></svg>',
  },
}
// Without an icon
firstName: {
  data: "Joe",
  description: "The name of Joe"
}

Interactive example

<ic-data-tablecaption="Description and icons within cells"table-layout="auto"></ic-data-table>

Missing cell data

If cell data is missing (represented as eithernull ,undefined or"" ) then the data table will still render an empty placeholder cell.

Interactive example

<ic-data-tablecaption="Missing cell data"></ic-data-table>

Select rows

By settingrowSelection totrue , ic-checkbox elements will appear in the leftmost column, with one in the header. When checked, the corresponding row will be selected, with theicSelectedRowChange containing the selected row and an array of all the currently selected rows.

When checking the header checkbox, all rows will be selected, with theicSelectAllRows event being emitted with an array of all the rows. When using pagination, only the rows on the current page will be selected.

Interactive example

<ic-data-tablecaption="Select rows with checkbox"row-selection="true"></ic-data-table>

Hidden columns

Addinghidden: true to the column object hides that column. In this example, the Quantity column is hidden.

Interactive example

<ic-data-tablecaption="Hidden columns"></ic-data-table>

Last reviewed 22 July 2025 .
Navigated to Data table - Intelligence Community Design System