Tables display tabular data in columns and rows. They organize information to enable users to navigate, view, search, sort, and edit the rows listed.

Example

⌘ Cmd + ⌥ Option + 1

Properties

"Table.TH" Component
propertypropTyperequireddefaultdescription
isCollapsedbool-false Tell the cell to take up the least amount of width possible. This only
works well if the table layout is `auto`, not `fixed`.
isNumericalbool-falseRight-align the cell if the contents are numerical
childrennode--Content within the `Table.TH` component
colSpannumber--Number of columns that the cell should span
testSectionstring--Hook for automated JavaScript tests
widthstring--A number with a unit that becomes the width of the `Table` cell
"Table.TR" Component
propertypropTyperequireddefaultdescription
backgroundColoroneOf 'faint' | 'light'--Background color for each row
borderStyleoneOf 'bottom' | 'top' | 'sides' | 'ends' | 'none'--Border style for each row
childrennode--Expects a `Table.TD` or `Table.TH` component
isActivebool--If true, add active class
noBorderbool--If true, add class to remove border
testSectionstring--Hook for automated JavaScript tests
"Table.THead" Component
propertypropTyperequireddefaultdescription
childrennode--Should be a `Table.TR` component
testSectionstring--Hook for automated JavaScript tests
"Table.TD" Component
propertypropTyperequireddefaultdescription
isNumericalbool-falseRight-align the cell if the contents are numerical
childrennode--Content within the `Table.TD` component
colSpannumber--Number of columns that the cell should span
testSectionstring--Hook for automated JavaScript tests
verticalAlignoneOf 'middle'--Apply a class that vertically aligns the cells within the children
widthstring--A number with a unit that becomes the width of the `Table` cell
"Table.TBody" Component
propertypropTyperequireddefaultdescription
childrennode--Should be a `Table.TR` component
testSectionstring--Hook for automated JavaScript tests
"Table" Component
propertypropTyperequireddefaultdescription
densityoneOf 'tight' | 'loose'-'tight'Sets the padding within cells
tableLayoutAlgorithmoneOf 'auto' | 'fixed'-'fixed' Adjust the [CSS `table-layout` property](https://developer.mozilla.org/en-US/docs/Web/CSS/table-layout)
that is used to calculate the with of inner table cells.
childrennode--Should be a `Table.THead` or `Table.TBody`
shouldAddHoverbool--Whether to set the hover class on the Table
styleoneOf 'wall' | 'rule' | 'rule-no-bottom-border'--Available border and hover options
testSectionstring--Hook for automated JavaScript tests

Usage

A table is used to display rows of information. Each table has a fixed number of columns, but the number of rows may vary. The data displayed in the cell of a table can be text, numeric, or have an action.

Table Sizing

Loose

Loose tables are the most common size, and are easy to read and parse. They're considered to be the default table style. Use these in all dashboards and most areas of the product.

Tight

Use tight tables when you need to display small, bite-sized pieces of information -- such as the conversion rates for a given variation -- in a compact space. Information is tightly clustered in these tables, so they shouldn't be used for dashboards or other long scrolling tables that contain a lot of information.

Considerations

Controls

Table cells may contain controls. Generally the controls follow the dialog alignment hueristic of being as far to the right as possible. Consider placing controls to the right side of the table, or in the last column.

Labeling

Table headers should be consise and clear. Each row should provide some identifier such as the name of the item listed in the table. Usually clicking the identifier allows users to edit or expose more information about that particular item.

Sorting

Make tables sortable by as many columns as possible, including columns that contain elements other than numbers or text -- such as "status." Users should be able to sort the table by status, or other indicators.

Columns that only contain controls should not be sortable by column.

Decide on a logical default column to sort by for each table. In our product, the default column is usually the "Created" column, which displays the date on which the item was created. This makes it easy for users to find the what they're looking for in the table, even when items are renamed or reordered.

Filtering

Although not a component of the table directly, a facilty to filter the table should be provided in most cases. This is espeically true for tables that contain many items.

Alignment

Align the text of numeric cells and numeric dates to the right. This makes tabular data of different lengths easier to read.

Best Practices

Do

Make as many columns sortable as possible.

Pick a logical default sort, like "Date Created."

Keep table headers consistent.

Don't

Use different data types in the same column. Keep them consistent.

Add too many columns. Choose the most important information and allow users to dig deeper.

Have too many controls. Limit to one or two actions per row.