Data table
Data table
Component demo
Interactive example
<ic-data-tablecaption="Basic Table"></ic-data-table>
<IcDataTablecaption="Basic"columns={columns}data={data}/>
Data table details
Props
All components also accept native properties supported by the DOM, such asclassName
and
style
.
|
|
|
---|---|---|
|
The title for the table only visible to screen readers. |
|
|
The column headers for the table. |
|
|
Determines whether the column header should be truncated and display a tooltip. Default is |
|
|
The row content for the table. |
|
|
Set the density of the table including font and padding. |
|
|
Applies a border to the table container. |
|
|
Sets the row height on all rows in the table that aren't set using the |
|
|
Sets the table height. Can be set to |
|
|
If |
|
|
When set to |
|
|
Sets the props for the circular loading indicator used in the loading state. |
|
|
Sets the maximum width of the data table. Can be set in |
|
|
Sets the minimum width of the data table. Can be set in |
|
|
The minimum amount of time the |
|
|
Sets the props for the built-in pagination bar. If the |
|
|
If |
|
|
Sets the order columns will be sorted in and allows for 'default' sorts to be added. |
|
|
If |
|
|
If |
|
|
If |
|
|
Sets the layout of the table |
|
|
Sets the method used to truncate long text in cells where textWrap is |
|
|
If |
|
|
Sets the props for the linear loading indicator used in the updating state. |
|
|
Allows for custom setting of row heights on individual rows based on an individual value from the |
|
|
Sets the table width. Can be set to |
|
The title for the table only visible to screen readers. |
The column headers for the table. |
Determines whether the column header should be truncated and display a tooltip. Default is |
The row content for the table. |
Set the density of the table including font and padding. |
Applies a border to the table container. |
Sets the row height on all rows in the table that aren't set using the |
Sets the table height. Can be set to |
If |
When set to |
Sets the props for the circular loading indicator used in the loading state. |
Sets the maximum width of the data table. Can be set in |
Sets the minimum width of the data table. Can be set in |
The minimum amount of time the |
Sets the props for the built-in pagination bar. If the |
If |
Sets the order columns will be sorted in and allows for 'default' sorts to be added. |
If |
If |
If |
Sets the layout of the table |
Sets the method used to truncate long text in cells where textWrap is |
If |
Sets the props for the linear loading indicator used in the updating state. |
Allows for custom setting of row heights on individual rows based on an individual value from the |
Sets the table width. Can be set to |
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.
|
|
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Events
All components also accept native events supported by the DOM, such as
onClick
and
onKeyDown
.
|
|
|
---|---|---|
|
|
|
|
|
|
|
|
Methods
|
|
|
---|---|---|
|
|
|
|
Variants
Embedded
Interactive example
<ic-data-tablecaption="Embedded Table"embedded="true"></ic-data-table>
<IcDataTablecaption="Embedded"columns={columns}data={data}embedded/>
Dense
Interactive example
<ic-data-tablecaption="Dense Table"density="dense"></ic-data-table>
<IcDataTablecaption="Dense"columns={columns}data={data}density="dense"/>
Spacious
Interactive example
<ic-data-tablecaption="Spacious Table"density="spacious"></ic-data-table>
<IcDataTablecaption="Spacious"columns={columns}data={data}density="spacious"/>
Sticky column headers
Interactive example
<ic-data-tablecaption="Sticky header Table"sticky-column-headers="true"></ic-data-table>
<IcDataTableclassName={classes.dataTable}caption="Sticky Column Headers"columns={long_columns}data={long_data}stickyColumnHeadersref={dataTableEl}/>
Row headers
Interactive example
<ic-data-tablecaption="Row headers"></ic-data-table>
<IcDataTablecaption="Row Headers"columns={columns}data={data}/>
Sortable
Interactive example
<ic-data-tablecaption="Sort"sortable="true"></ic-data-table>
<IcDataTablecaption="Sort"columns={columns}data={data}sortableonIcSortChange={(e)=>console.log("Sort changed", e.detail)}/>
Sort options
Interactive example
<ic-data-tablecaption="Sort Options"sortable="true"></ic-data-table>
<IcDataTablecaption="Sort Options"columns={columns}data={data}sortablesortOptions={{ sortOrders:["descending","unsorted"], defaultColumn:"firstName",}}/>
Pagination
Interactive example
<ic-data-tablecaption="Pagination"show-pagination="true"></ic-data-table>
<IcDataTablecaption="Pagination"columns={long_columns}data={long_data}showPaginationpaginationOptions={{ itemsPerPage:[{ label:"5", value:"5"},{ label:"10", value:"10"},{ label:"15", value:"15"},], itemsPerPageControl:true,}}/>
Column overrides
Interactive example
<ic-data-tablecaption="Column Overrides"></ic-data-table>
<IcDataTablecaption="Column overrides"columns={columns}data={data}/>
Row overrides
Interactive example
<ic-data-tablecaption="Row Overrides"></ic-data-table>
<IcDataTablecaption="Row overrides"columns={columns}data={data}/>
Cell overrides
Interactive example
<ic-data-tablecaption="Cell Overrides"></ic-data-table>
<IcDataTablecaption="Cell overrides"columns={columns}data={data}/>
Default Empty State
Interactive example
<ic-data-tablecaption="Default Empty State"></ic-data-table>
<IcDataTablecaption="Default Empty State"columns={columns}/>
Slotted Empty State
Interactive example
<ic-data-tableid="data-table"caption="Slotted Empty State"><ic-empty-statealigned="left"heading="Data source error"body="Error loading new data"><ic-buttonslot="actions">Retry</ic-button></ic-empty-state></ic-data-table>
<IcDataTablecaption="Slotted Empty State"columns={columns}><IcEmptyStateslot="empty-state"aligned="left"heading="Data source error"body="Error loading new data"><IcButtonslot="actions">Retry</IcButton></IcEmptyState></IcDataTable>
Loading state
Interactive example
<ic-data-tableid="data-table"caption="Loading State"></ic-data-table>
<IcDataTablecaption="Loading state"columns={columns}data={data}loading/>
Updating state
Interactive example
<ic-data-tableid="data-table"caption="Updating State"></ic-data-table>
<IcDataTablecaption="Updating state"columns={columns}data={data}updatingupdatingOptions={{ progress:30}}/>
Links and Elements in data
Interactive example
<ic-data-tablecaption="Links and Elements in data"></ic-data-table>
<IcDataTablecaption="Links and Elements in data"columns={columns}data={data}>{data.map((_, index)=>(<IcButtonkey={index}slot={`actions-${index}`}variant="destructive"onClick={()=> _.closest('Delete')}> Delete</IcButton>))}</IcDataTable>
Custom icons
Interactive example
<ic-data-tableid="data-table"caption="Custom Icons"><svgslot="age-column-icon"xmlns="http://www.w3.org/2000/svg"viewBox="0 0 24 24"><pathd="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>
<IcDataTablecaption="Custom icons"columns={columns}data={data}><SlottedSVGslot="age-column-icon"path={mdiCakeVariantOutline}/></IcDataTable>
Custom row heights
Interactive example
<ic-data-tableid="data-table"caption="Custom Row Heights"></ic-data-table>
<IcDataTablecaption="Custom Row Heights"columns={columns}data={data}globalRowHeight={80}variableRowHeight={rowHeightFunc}/>
Custom title bar
Interactive example
This is some text and
<ic-data-tableid="data-table"caption="Custom Title Bar"><ic-data-table-title-bardescription="Data table description that describes the purpose of the table."metadata="128 items | 32gb | Updated: 01/02/03"><ic-buttonslot="primary-action">Primary</ic-button><ic-buttonslot="custom-actions"variant="icon"aria-label="Icon 1"><svgxmlns="http://www.w3.org/2000/svg"height="24"viewBox="0 -960 960 960"width="24"><pathd="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="Icon 2"><svgxmlns="http://www.w3.org/2000/svg"height="24"viewBox="0 -960 960 960"width="24"><pathd="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="Icon 3"><svgxmlns="http://www.w3.org/2000/svg"height="24"viewBox="0 -960 960 960"width="24"><pathd="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> This is some text and{' '}<ic-linkhref="#">this is an inline link</ic-link> within the text.</p></ic-typography></ic-data-table-title-bar></ic-data-table>
<IcDataTablecaption="Custom Title Bar"columns={columns}data={data}><IcDataTableTitleBarslot="title-bar"description="Data table description that describes the purpose of the table."metadata="128 items | 32gb | Updated: 01/02/03"><IcButtonslot="primary-action">Primary</IcButton><IcButtonslot="custom-actions"variant="icon"aria-label="Icon 1"><SlottedSVGpath={mdiImage}viewBox="0 0 24 24"/></IcButton><IcButtonslot="custom-actions"variant="icon"aria-label="Icon 2"><SlottedSVGpath={mdiImage}viewBox="0 0 24 24"/></IcButton><IcButtonslot="custom-actions"variant="icon"aria-label="Icon 3"><SlottedSVGpath={mdiImage}viewBox="0 0 24 24"/></IcButton><IcTypographyslot="description"variant="body"><p> This is some text and{' '}<IcLinkhref="#">this is an inline link</IcLink> within the text.</p></IcTypography></IcDataTableTitleBar></IcDataTable>
Truncation - tooltip
Interactive example
<ic-data-tablecaption="Data table truncation - tooltip"truncation-pattern="tooltip"></ic-data-table>
<IcDataTablecaption="Data table truncation - tooltip"columns={columns}data={data}truncationPattern="tooltip"globalRowHeight={40}/>
Truncation - show/hide
Interactive example
<ic-data-tablecaption="Data table truncation - show/hide"truncation-pattern="show-hide"></ic-data-table>
<IcDataTablecaption="Data table truncation - show/hide"columns={columns}data={data}truncationPattern="show-hide"globalRowHeight={40}/>
Text wrap
Interactive example
<ic-data-tablecaption="Data table text wrap"></ic-data-table>
<IcDataTablecaption="Data table text wrap"columns={columns}data={data}globalRowHeight={40}/>