Tables

EUI provides opinionated and non-opinionated ways to build tables

Tables can get complicated very fast. If you're just looking for a basic table with pagination, sorting, checkbox selection, and actions then you should use EuiBasicTable. It's a high level component that removes the need to worry about constructing individual components together. You simply arrange your data in the format it asks for.

However if your table is more complicated, you can still use the individual table components like rows, headers, and pagination separately to do what you need. Find examples for that at the bottom of this page.

A simple BasicTable

EuiBasicTable is an opinionated high level component that standardizes both display and injection. At its most simple it only accepts two properties:

  • items are an array of objects that should be displayed in the table; one item per row. The exact item data that will be rendered in each cell in these rows is determined by the columns property. You can define rowProps and cellProps props which can either be objects or functions that return objects. The returned objects will be applied as props to the rendered rows and row cells, respectively.
  • columns defines what columns the table has and how to extract item data to display each cell in each row.

This example shows the most basic form of the EuiBasicTable. It is configured with the required items and columns properties. It shows how each column defines the data it needs to display per item. Some columns display the value as is (e.g. firstName and lastName fields for the user column). Other columns customize the display of the data before it is injected. This customization can be done in two (non-mutual exclusive) ways:

  • Provide a hint about the type of data (e.g. the "Date of Birth" column indicates that the data it shows is of type date). Providing data type hints will cause built-in display components to be adjusted (e.g. numbers will become right aligned, just like Excel).
  • Provide a render function that given the value (and the item as a second argument) returns the React node that should be displayed as the content of the cell. This can be as simple as formatting values (e.g. the "Date of Birth" column) to utilizing more complex React components (e.g. the "Online", "Github", and "Nationality" columns as seen below).
    Note: the basic table will treat any cells that use a render function as being textOnly: false. This may cause unnecessary word breaks. Apply textOnly: true to ensure it breaks properly.
Below is a table of 10 items.
First Name
Last Name
Github
Date of Birth
Nationality
Online
Very long first name that will wrap or be truncated Very long last name that will wrap or be truncated
Very long first name that will wrap or be truncated
Github
martijnvg
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇳🇱 Netherlands
Online
Online
Another very long first name which will wrap or be truncated Another very long last name which will wrap or be truncated
Another very long first name which will wrap or be truncated
Github
elissaw
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇨🇿 Czech Republic
Online
Offline
Clinton Gormley
Clinton
Github
clintongormley
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇿🇦 South Africa
Online
Online
Igor Motov
Igor
Github
imotov
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇺🇲 United States
Online
Offline
Github
karmi
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇦🇺 Australia
Online
Online
Drew Raines
Drew
Github
drewr
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇮🇱 Israel
Online
Offline
Github
HonzaKral
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇳🇴 Norway
Online
Online
Rashid Khan
Rashid
Github
rashidkpc
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇮🇹 Italy
Online
Offline
Github
jordansissel
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇨🇦 Canada
Online
Online
John Dorlus
John
Github
silne30
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇨🇬 Congo
Online
Offline

Adding pagination to a BasicTable

The following example shows how to configure pagination via the paginationproperty.

Hide per page options with pagination.hidePerPageOptions = true

Below is a table of 5 items.
First Name
Last Name
Full Name
Github
Date of Birth
Nationality
Online
Very long first name that will wrap or be truncated
Very long last name that will wrap or be truncated
Very long first name that will wrap or be truncated Very long last name that will wrap or be truncated
Online
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇳🇱 Netherlands
Online
Online
Another very long first name which will wrap or be truncated
Another very long last name which will wrap or be truncated
Another very long first name which will wrap or be truncated Another very long last name which will wrap or be truncated
Offline
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇨🇿 Czech Republic
Online
Offline
Clinton
Gormley
Clinton Gormley
Online
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇿🇦 South Africa
Online
Online
Igor
Motov
Igor Motov
Offline
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇺🇲 United States
Online
Offline
Minarik
Minarik
Online
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇦🇺 Australia
Online
Online

Adding sorting to a BasicTable

The following example shows how to configure column sorting via the sortingproperty and flagging the sortable columns as sortable: true

Below is a table of 5 items.
Another very long first name which will wrap or be truncated Another very long last name which will wrap or be truncated
Another very long first name which will wrap or be truncated
Another very long last name which will wrap or be truncated
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇨🇿 Czech Republic
Online
Offline
Another very long first name which will wrap or be truncated Another very long last name which will wrap or be truncated
Another very long first name which will wrap or be truncated
Another very long last name which will wrap or be truncated
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇫🇯 Fiji
Online
Offline
Clinton Gormley
Clinton
Gormley
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇿🇦 South Africa
Online
Online
Clinton Gormley
Clinton
Gormley
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇬🇧 United Kingdom
Online
Online
Drew Raines
Drew
Raines
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇮🇱 Israel
Online
Offline

Adding selection to a BasicTable

The following example shows how to configure selection via the selectionproperty.

Below is a table of 5 items.
Last Name
Full Name
Github
Nationality
Another very long first name which will wrap or be truncated
Another very long last name which will wrap or be truncated
Another very long first name which will wrap or be truncated Another very long last name which will wrap or be truncated
Offline
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇨🇿 Czech Republic
Offline
Another very long first name which will wrap or be truncated
Another very long last name which will wrap or be truncated
Another very long first name which will wrap or be truncated Another very long last name which will wrap or be truncated
Offline
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇫🇯 Fiji
Offline
Clinton
Gormley
Clinton Gormley
Online
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇿🇦 South Africa
Online
Clinton
Gormley
Clinton Gormley
Online
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇬🇧 United Kingdom
Online
Drew
Raines
Drew Raines
Offline
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇮🇱 Israel
Offline

Expanding rows

You can expand rows by passing in a itemIdToExpandedRowMap prop which will contain the content you want rendered inside the expanded row. When building out your table manually (not using EuiBasicTable), you will also need to add the prop isExpandedRow to the row that will be revealed.

Below is a table of 5 items.
Last Name
Actions
Another very long first name which will wrap or be truncated Another very long last name which will wrap or be truncated
Another very long first name which will wrap or be truncated
Another very long last name which will wrap or be truncated
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Another very long first name which will wrap or be truncated Another very long last name which will wrap or be truncated
Another very long first name which will wrap or be truncated
Another very long last name which will wrap or be truncated
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Clinton Gormley
Clinton
Gormley
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Clinton Gormley
Clinton
Gormley
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Drew Raines
Drew
Raines
Date of Birth
1st Ƒéƀƀŕûààŕý 1980

Adding actions to BasicTable

The following example demonstrates "actions" columns. These are special columns where you define per-row, item level actions. The most basic action you might define is a type button or icon though you can always make your own custom actions as well.

Actions enforce some strict UI/UX guidelines:

  • There can only be up to 2 actions visible per row. When more than two actions are defined, the first 2 isPrimary actions will stay visible, an ellipses icon button will hold all actions in a single popover.
  • Actions change opacity when user hovers over the row with the mouse. When more than 2 actions are supplied, only the ellipses icon button stays visible at all times.

Multiple Actions

Custom Actions

Below is a table of 5 items.
Last Name
Github
Nationality
Actions
Another very long first name which will wrap or be truncated Another very long last name which will wrap or be truncated
Another very long first name which will wrap or be truncated
Another very long last name which will wrap or be truncated
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇨🇿 Czech Republic
Online
Offline
Another very long first name which will wrap or be truncated Another very long last name which will wrap or be truncated
Another very long first name which will wrap or be truncated
Another very long last name which will wrap or be truncated
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇫🇯 Fiji
Online
Offline
Clinton Gormley
Clinton
Gormley
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇿🇦 South Africa
Online
Online
Clinton Gormley
Clinton
Gormley
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇬🇧 United Kingdom
Online
Online
Drew Raines
Drew
Raines
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇮🇱 Israel
Online
Offline

In-Memory Table

The EuiInMemoryTable is a higher level component wrapper around EuiBasicTable that aimed at displaying tables data when all the data is in memory. It takes the full set of data (all possible items) and based on its configuration, will display it handling all configured functionality (pagination and sorting) for you.

Below is a table of 10 items.
Last Name
Github
Nationality
First Name
Very long first name that will wrap or be truncated
Last Name
Very long last name that will wrap or be truncated
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇳🇱 Netherlands
Online
Online
First Name
Another very long first name which will wrap or be truncated
Last Name
Another very long last name which will wrap or be truncated
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇨🇿 Czech Republic
Online
Offline
First Name
Clinton
Last Name
Gormley
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇿🇦 South Africa
Online
Online
First Name
Igor
Last Name
Motov
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇺🇲 United States
Online
Offline
First Name
Last Name
Minarik
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇦🇺 Australia
Online
Online
First Name
Drew
Last Name
Raines
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇮🇱 Israel
Online
Offline
First Name
Last Name
Král
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇳🇴 Norway
Online
Online
First Name
Rashid
Last Name
Khan
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇮🇹 Italy
Online
Offline
First Name
Last Name
Sissel
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇨🇦 Canada
Online
Online
First Name
John
Last Name
Dorlus
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇨🇬 Congo
Online
Offline

In-Memory Table - Selection

The following example shows how to use EuiInMemoryTable along with item selection. It also shows how you can display messages, errors and show loading indication.

Below is a table of 0 items.
Last Name
Github
Nationality

No users

Looks like you don’t have any users. Let’s create some!

In-Memory Table - With Search Callback

The example shows how to configure EuiInMemoryTable to display a search bar and intercept the search value when it changes so you can perform your own search logic.

Below is a table of 10 items.
Last Name
Github
Nationality
First Name
Very long first name that will wrap or be truncated
Last Name
Very long last name that will wrap or be truncated
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇳🇱 Netherlands
Online
Online
First Name
Another very long first name which will wrap or be truncated
Last Name
Another very long last name which will wrap or be truncated
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇨🇿 Czech Republic
Online
Offline
First Name
Clinton
Last Name
Gormley
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇿🇦 South Africa
Online
Online
First Name
Igor
Last Name
Motov
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇺🇲 United States
Online
Offline
First Name
Last Name
Minarik
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇦🇺 Australia
Online
Online
First Name
Drew
Last Name
Raines
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇮🇱 Israel
Online
Offline
First Name
Last Name
Král
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇳🇴 Norway
Online
Online
First Name
Rashid
Last Name
Khan
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇮🇹 Italy
Online
Offline
First Name
Last Name
Sissel
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇨🇦 Canada
Online
Online
First Name
John
Last Name
Dorlus
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇨🇬 Congo
Online
Offline

In-Memory Table - Custom sort values

Sometimes the value displayed in a column is not appropriate to use for sorting, such as pre-formatting values to be human-readable. In these cases it's possible to pass the sortable prop as a function instead of true or false. The function is used to extract or calculate the intended sort value for each item.

Below is a table of 6 items.
Animal
snail
Weight
0.025kg
Weight (grams)
25
Animal
peregrine falcon
Weight
0.9kg
Weight (grams)
900
Animal
small dog
Weight
4.5kg
Weight (grams)
4500
Animal
brown bear
Weight
180kg
Weight (grams)
180000
Animal
giraffe
Weight
1180kg
Weight (grams)
1180000
Animal
elephant
Weight
5440kg
Weight (grams)
5440000

Responsive tables

Allowing a table to be responsive means breaking each row down into its own section and individually displaying each table header above the cell contents. There are few times when you may want to exclude this behavior from your table, for instance, when the table has very few columns or the table does not break down easily into this format. For these use cases, you may set responsive = false.

To make your table work responsively, please make sure you add the following additional props to the top level table component (EuiBasicTable or EuiInMemoryTable):

  • isSelectable: if the table has a single column of checkboxes for selecting rows
  • isExpandable: if the table has rows that can expand
  • hasActions: if the table has a column for actions which may/may not be hidden in hover

The mobileOptions object can be passed to the EuiTableRowCell directly or with each column item provided to EuiBasicTable.

{
  field: 'firstName',
  name: 'First Name',
  truncateText: true,
  mobileOptions: {
    render: (item) => (<span>{item.firstName} {item.lastName}</span>), // Custom renderer for mobile view only
    header: false,   // Won't show inline header in mobile view
    fullWidth: true, // Forces 100% width of the cell
    enlarge: true,   // Increase text size compared to rest of cells
    truncateText: false, // Only works if a 'render()' is also provided
  }
}

Note:

You can also change basic table row cell props like truncateText and textOnly for mobile layouts, though you must also be passing a mobile specific render function.

Responsive

Custom header

Below is a table of 5 items.
Last Name
Github
Nationality
Actions
Another very long first name which will wrap or be truncated Another very long last name which will wrap or be truncated
Another very long first name which will wrap or be truncated
Another very long last name which will wrap or be truncated
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇨🇿 Czech Republic
Online
Offline
Another very long first name which will wrap or be truncated Another very long last name which will wrap or be truncated
Another very long first name which will wrap or be truncated
Another very long last name which will wrap or be truncated
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇫🇯 Fiji
Online
Offline
Clinton Gormley
Clinton
Gormley
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇿🇦 South Africa
Online
Online
Clinton Gormley
Clinton
Gormley
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇬🇧 United Kingdom
Online
Online
Drew Raines
Drew
Raines
Github
Date of Birth
1st Ƒéƀƀŕûààŕý 1980
Nationality
🇮🇱 Israel
Online
Offline

Build a custom table from individual components

As an alternative to EuiBasicTable you can instead construct a table from individual low level, basic components like EuiTableHeader and EuiTableRowCell. Below is one of many ways you might set this up on your own. Important to note are how you need to 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.

Responsive extras

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, custom table implementations will not auto-populate any header level functions like selection and filtering. In order to add mobile support for these functions, 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.

Title
Health
A very long line which will wrap on narrower screens and NOT become truncated and replaced by an ellipsis
A very long line which will wrap on narrower screens and NOT become truncated and replaced by an ellipsis
Health
Healthy
Date created
Tue Dec 28 2016
Orders of magnitude
1
A very long line which will not wrap on narrower screens and instead will become truncated and replaced by an ellipsis
A very long line which will not wrap on narrower screens and instead will become truncated and replaced by an ellipsis
Health
Healthy
Date created
Tue Dec 01 2016
Orders of magnitude
1
A very long line in an ELEMENT which will wrap on narrower screens and NOT become truncated and replaced by an ellipsis
A very long line in an ELEMENT which will wrap on narrower screens and NOT become truncated and replaced by an ellipsis
Health
Warning
Date created
Tue Dec 01 2016   New!
Orders of magnitude
10
A very long line in an ELEMENT which will not wrap on narrower screens and instead will become truncated and replaced by an ellipsis
A very long line in an ELEMENT which will not wrap on narrower screens and instead will become truncated and replaced by an ellipsis
Health
Healthy
Date created
Tue Dec 16 2016
Orders of magnitude
100
Health
Warning
Date created
Tue Dec 13 2016
Orders of magnitude
1000
Health
Healthy
Date created
Tue Dec 11 2016
Orders of magnitude
10000
Health
Danger
Date created
Tue Dec 11 2016
Orders of magnitude
10000
Health
Warning
Date created
Tue Dec 11 2016
Orders of magnitude
10000
Health
Warning
Date created
Tue Dec 11 2016
Orders of magnitude
10000
Health
Healthy
Date created
Tue Dec 11 2016
Orders of magnitude
10000
Title
Date created
Total: 51112