Custom tables
If you need more custom behavior than either EuiBasicTable or EuiInMemoryTable allow, you can opt to completely construct your own table from EUI's low-level table building block components, like EuiTableHeaderΒ and EuiTableRowCell.
There are several important caveats to keep in mind while doing so:
Selection and filtering
Custom table implementations must completely handle their own selection and filtering.
Mobile headers
You must supply a mobileOptions.header prop equivalent to the column header on each EuiTableRowCell so that the mobile version will use that to populate the per cell headers.
Also, in order to add mobile support for selection and filtering toolbars, you will need to implement the EuiTableHeaderMobile component as a wrapper around these and use EuiTableSortMobileΒ and EuiTableSortMobileItem components to supply mobile sorting. See demo below.
Cell text behavior
Set individual props like the truncateText prop to cells to enforce a single-line behavior and truncate their contents, or set the textOnly prop to false if you need the contents to be a direct descendent of the cell.
Below is one of many ways you might set up a custom table that account for all the above notes:
Props
EuiTable
Prop | Description and type | Default value |
|---|---|---|
Prop compressed# | Description and type Type: boolean | Default value |
Prop responsiveBreakpoint# | Description and type Named breakpoint. Below this size, the table will collapse Pass string | boolean | Default value m |
Prop tableLayout# | Description and type Sets the table-layout CSS property "fixed" | "auto" | Default value 'fixed' |
Prop hasBackground# | Description and type Toggle the table's background boolean | Default value true |
Prop scrollableInline# | Description and type Allow the table to grow over 100% of the container inline size This should only be used with [ boolean | Default value false |
Prop className# | Description and type Type: string | Default value |
Prop aria-label# | Description and type Type: string | Default value |
Prop data-test-subj# | Description and type Type: string | Default value |
Prop css# | Description and type Type: Interpolation<Theme> | Default value |
EuiTableBody
Prop | Description and type | Default value |
|---|---|---|
Prop className# | Description and type Type: string | Default value |
Prop aria-label# | Description and type Type: string | Default value |
Prop data-test-subj# | Description and type Type: string | Default value |
Prop css# | Description and type Type: Interpolation<Theme> | Default value |
Prop bodyRef# | Description and type Type: Ref<HTMLTableSectionElement> | Default value |
EuiTableFooterCell
Prop | Description and type | Default value |
|---|---|---|
Prop className# | Description and type Type: string | Default value |
Prop aria-label# | Description and type Defines a string value that labels the current element. string | Default value |
Prop data-test-subj# | Description and type Type: string | Default value |
Prop css# | Description and type Type: Interpolation<Theme> | Default value |
Prop sticky# | Description and type Whether the cell should stick to a side of the table. This option is not applied in the responsive cards layout - see Currently, it can only be used when the cell is in the first or the last When set to EuiTableStickyCellOptions | Default value false |
EuiTableHeader
Prop | Description and type | Default value |
|---|---|---|
Prop className# | Description and type Type: string | Default value |
Prop aria-label# | Description and type Defines a string value that labels the current element. string | Default value |
Prop data-test-subj# | Description and type Type: string | Default value |
Prop css# | Description and type Type: Interpolation<Theme> | Default value |
Prop children# | Description and type Children must be valid DOM structure residing within ReactNode | Default value |
Prop wrapWithTableRow# | Description and type Automatically adds a wrapping boolean | Default value true |
EuiTableHeaderCell
Prop | Description and type | Default value |
|---|---|---|
Prop className# | Description and type Type: string | Default value |
Prop aria-label# | Description and type Defines a string value that labels the current element. string | Default value |
Prop data-test-subj# | Description and type Type: string | Default value |
Prop css# | Description and type Type: Interpolation<Theme> | Default value |
Prop align# | Description and type Type: HorizontalAlignment | Default value left |
Prop isSortAscending# | Description and type Type: boolean | Default value |
Prop isSorted# | Description and type Type: boolean | Default value |
Prop mobileOptions# | Description and type Type: Pick<EuiTableRowCellMobileOptionsShape, "show" | "only"> | Default value |
Prop onSort# | Description and type Type: NoArgCallback<void> | Default value |
Prop scope# | Description and type Type: "col" | "colgroup" | "row" | "rowgroup" | Default value |
Prop width# | Description and type Type: string | number | Default value |
Prop tooltipProps# | Description and type Allows adding an icon with a tooltip displayed next to the name EuiTableColumnNameTooltipProps | Default value |
Prop description# | Description and type Type: string | Default value |
Prop readOnly# | Description and type Shows the sort indicator but removes the button boolean | Default value |