# Datatable

<figure><img src="https://zeroheight.com/uploads/qJb_H93CdHb5jZlUQbei0g.png" alt=""><figcaption></figcaption></figure>

## Overview <a href="#id-3479b3" id="id-3479b3"></a>

Datatables are made to display information in a grid format with rows and columns. They show data in a way that is easy to scan and let users perform actions to manage their content.

Datatable should be used:

* to display complex data in an easy-to-scan way,
* if users need to sort on multiple columns,
* if users need column titles to make sure the context and content are clear,
* if data needs to be displayed in a controlled way (using pre-formatted cells).

Datatable should not be used:

* To display a collection of items with an elaborate layout (use [Datalist](https://design.mirakl.com/~/changes/DpgERwSwrKIthStzL4D6/components/datalist)),
* To highlight part of a data set (use **Data Visualization**).

{% hint style="info" %}
Having trouble deciding between Datalist and Datatable? Head over to the [Displaying data pattern](https://design.mirakl.com/~/changes/DpgERwSwrKIthStzL4D6/patterns/displaying-data)
{% endhint %}

Datatable has features that let users interact with the content:

* Column headers can sort data,
* Filters let users view different subsets of data,
* Single or bulk actions can be performed,
* Export lets users download the data set in different file formats,
* Data can be added or reordered,
* Pagination lets users navigate through the entire data set.

## Guidelines <a href="#id-33d52f" id="id-33d52f"></a>

<figure><img src="https://zeroheight.com/uploads/Ji6IMJUe308Dek1fFnakHg.png" alt=""><figcaption></figcaption></figure>

| <p>1. <strong>Title</strong>: clearly states the content of the datatable.</p><p>2. <a href="#912e88"><strong>Toolbar</strong></a>: has interactive elements such as a search bar and filters. Also has options like letting users manage visual display and a call to action to add content to the data set.</p><p>3. <a href="#101ab5"><strong>Columns</strong></a><strong>:</strong> title of the columns and sorting behavior.</p><p>4. <a href="#088d06"><strong>Rows</strong></a>: show different data types with actions to edit and manage them.</p><p>5. <a href="#440909"><strong>Scrollbar</strong></a>: lets users scroll in the content both horizontally and vertically,</p><p>6. <a href="#78cd24"><strong>Footer and pagination</strong></a>: navigating the entire data set.</p> |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

### Toolbar <a href="#id-912e88" id="id-912e88"></a>

<figure><img src="https://zeroheight.com/uploads/O5pGcYKbYrxQLfrdzQsNZQ.png" alt=""><figcaption></figcaption></figure>

The datatable toolbar can have different elements:&#x20;

* Search (standard or on a specific column)
* Filters
* Number of items or results
* Column management
* Density management
* Export feature
* [Action button](https://zeroheight.com/065715af6/p/36c855-buttons/b/218857)

### Selection <a href="#id-55a556" id="id-55a556"></a>

<figure><img src="https://zeroheight.com/uploads/OBbe54yh_0bZR_Qwk5AXAg.png" alt=""><figcaption></figcaption></figure>

Datatable allows users to select rows through bulk selection, on which they can take action. A bulk bar appears with one or several actions.

You can select all items from the data set, all items on the page, or deselect all items. Once you select all items from a table, you cannot unselect one item.

<figure><img src="https://1297765105-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMoZPkWOmnKvoMWGW4aeM%2Fuploads%2FdKl0BxjjOpwjFXhH7F7A%2FDatatable%20Bulk%20Actions.png?alt=media&#x26;token=f5c9e55b-5fff-4cb2-aba5-a0d02ef01cf4" alt=""><figcaption></figcaption></figure>

If you want to select a series of filtered elements, filter the data first, then select in bulk.

### Rows <a href="#id-088d06" id="id-088d06"></a>

#### States :

<figure><img src="https://1297765105-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMoZPkWOmnKvoMWGW4aeM%2Fuploads%2FAWntCI0wnTZ6Gbh8LMu3%2FRow%20type.png?alt=media&#x26;token=ddb2b4ab-8bf8-459a-bd67-abaead51ed2a" alt=""><figcaption></figcaption></figure>

* **Default:** row is clear, and actions are available. This is the standard row behavior.
* **Disabled:** row is greyed out, and actions are unavailable. For example, you may use it when a product is rejected, and no action can be taken to change its status.
* **Highlighted:** row has a ribbon to highlight it
* **Dimmed:** row is greyed out, but actions are still available. For example, you may use it when a product has been excluded from a selection, but you can reactivate it later.

#### Types:

<figure><img src="https://1297765105-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FMoZPkWOmnKvoMWGW4aeM%2Fuploads%2FtLCrUg5LK5eJcUNbLEIa%2FRow%20type.png?alt=media&#x26;token=062b7d20-c050-44cd-acb4-9737bf127582" alt=""><figcaption></figcaption></figure>

* **Selection :** rows are selectable and selection is managed with the bulk.
* **Reorder:** rows can be reordered.

#### Sizes:

<figure><img src="https://zeroheight.com/uploads/Cx-HI01kPFSIhkDnX1SqGA.png" alt=""><figcaption></figcaption></figure>

Rows are available in three sizes: *compact*, *default* (used by default), and *comfortable*. Users can change size with the density button in the filter bar.

### Cells <a href="#id-437031" id="id-437031"></a>

| **Content type** | **Cell type**                                                                                   | **Expand?** | **Subtext?** | **Tooltip?** | **Alignment** | **More info**                                                                                                                                                                        |
| ---------------- | ----------------------------------------------------------------------------------------------- | ----------- | ------------ | ------------ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Amount (price)   | MonetaryCellContent                                                                             | Yes         | Yes          | Yes          | Right         | <ul><li>Not possible to combine expandable + tooltip props</li><li>Currency is mandatory (ISO 4217 code)</li></ul>                                                                   |
| Date             | DateCellContent                                                                                 | Yes         | Yes          | Yes          | Right         | <ul><li>Not possible to combine expandable + tooltip props</li><li><a href="https://zeroheight.com/065715af6/p/610bf7-grammar-and-formatting/t/670dfc">Date formatting</a></li></ul> |
| Link             | <ul><li>If with Media: HrefMediaCellContent</li><li>If without Media: HrefCellContent</li></ul> | No          | Yes          | No           | Left          | <ul><li>Only use one href cell type per datatable.</li></ul>                                                                                                                         |
| Media            | <ul><li>If clickable: HrefMediaCellContent</li><li>If not clickable: MediaCellContent</li></ul> | No          | Yes          | No           | <p><br></p>   | <p><br></p>                                                                                                                                                                          |
| Number           | NumericCellContent                                                                              | Yes         | Yes          | Yes          | Right         | <ul><li>Not possible to combine expandable + tooltip props</li><li>Unit and percent props optional</li></ul>                                                                         |
| Paragraph        | ParagraphCellContent[^1]                                                                        | No          | No           | No           | Left          | <p><br></p>                                                                                                                                                                          |
| Rating[^2]       | R[^1]atingsCellContent[^3]                                                                      | Yes         | Yes          |              |               |                                                                                                                                                                                      |
| Status           | StatusCellContent                                                                               | No          | No           | Yes          | Left          | <p><br></p>                                                                                                                                                                          |
| Text             | TextCellContent                                                                                 | Yes         | Yes          | Yes          | Left          | <ul><li>Not possible to combine expandable + tooltip props</li></ul>                                                                                                                 |

**Expandable:** After clicking the chevron, extra content is displayed in a [popover ](https://design.mirakl.com/~/changes/DpgERwSwrKIthStzL4D6/components/overlays/popover)cell. Content can be structured and with a button.

If you need the line clickable, use a Href cell for accessibility.

### Columns <a href="#id-101ab5" id="id-101ab5"></a>

<figure><img src="https://zeroheight.com/uploads/jbBkohyFYU5_EYmC7cBOfA.gif" alt=""><figcaption></figcaption></figure>

Columns can be sorted.

Column width is defined by the largest content (cell and header) within a limit of 500 px. The width is overridable. Otherwise, the content is cut with an ellipsis.<br>

### Scrolling <a href="#id-440909" id="id-440909"></a>

#### **Horizontal**

When the content of a row is longer than the width of the panel, a floating trailing action is displayed. It ensures the user can perform an action on a row without scrolling.

<figure><img src="https://zeroheight.com/uploads/HCal3YzGWKekAHmEjqDPjw.png" alt=""><figcaption></figcaption></figure>

#### **Fixed header**

The column header is pinned while scrolling to ensure the readability of the cell content. The horizontal scrollbar is pinned to the bottom of the viewport to ensure it will always be visible and easily reached.

<figure><img src="https://zeroheight.com/uploads/-4EJDs9ScODQ8y3CyetSuA.gif" alt=""><figcaption></figcaption></figure>

### Loading <a href="#id-8584ed" id="id-8584ed"></a>

Datatable with skeleton

<figure><img src="https://zeroheight.com/uploads/xDNAknv5Sd-Kf8LIMbEHqw.gif" alt=""><figcaption></figcaption></figure>

Skeleton loading is fully automated for `Datatable.` [Learn more about Loading patterns](https://design.mirakl.com/~/changes/DpgERwSwrKIthStzL4D6/patterns/loading)

### Footer and pagination <a href="#id-78cd24" id="id-78cd24"></a>

We recommend 50, 100, and 200 as pagination thresholds.

When `Datatable` has a lot of content to display (for example, more than 1,234 results), Roma will display a globalized number. Define the threshold that is relevant to your need, usually +1,000.

### Empty state <a href="#id-978cb3" id="id-978cb3"></a>

💡 Empty state behavior is automatically handled by Roma. No results empty state behavior (with microcopy) is automatically handled by Roma.

Content for any other type of empty state has to be defined for each project. The toolbar (with the options you chose to add) is displayed in disabled mode, and the primary action is disabled. The same action is moved to the empty state.

<figure><img src="https://zeroheight.com/uploads/yQyl3qSoB0NsrXTWieC4HQ.jpg" alt=""><figcaption></figcaption></figure>

The empty state action is the same as the toolbar's, but you may override it. [Learn more about writing empty states](https://design.mirakl.com/~/changes/DpgERwSwrKIthStzL4D6/components/feedback/empty-state)

[^1]:

[^2]: [Romain Séchan](https://app.gitbook.com/u/8PliRmPt0BSSxKAqiniV6KjCHhz2 "mention") tu confirmes les infos pour cette cell ?

[^3]: [Romain Séchan](https://app.gitbook.com/u/8PliRmPt0BSSxKAqiniV6KjCHhz2 "mention")tu confirmes les infos pour la cell rating ?
