The table header shows contextual information about the table and render controls that affect the table.
A very short label that describes the data in the column.
Column headers are buttons that sort rows by the column data in ascending or descending order. Sort functionality may be disabled on a column-by-column basis.
The column that contains row actions does not have a visible column header.
A row header identifies the item being represented in the row. They are typically the first cell in the row, and are visually distinct from the other cells in the row.
Actions that affect the item represented in the row.
The data for each row that is described by its corresponding column header and optional row header.
The pagination footer shows the user where they are in relation to the total number of rows and provides controls for navigating all rows.
Data should be initially rendered in an intuitive order. For example, starting with the most recently created items.
By default, sort alphabetically by the first column's content. Rows will be re-ordered as the user updates the sort parameters
It's easier to scan many rows than it is to scan many columns. Consider swapping columns and rows when it's unlikely that there will ever be more rows than columns.
Use the column width options to appropriately size the columns depending on the content and the available horizontal space.
Column headers are short labels used to define the kind of data that is shown in that column.
Cells should represent data in the shortest possible format. This makes the table easier to scan, and preserves horizontal space.
The column header should accurately represent the data point rendered in the column's cells. It would also be unclear which data point is being used when sorting.
This makes it easier to compare the numbers in a column
Ideally, the cell content is very short and the column will be wide enough to accommodate its content. In cases where it's not possible to fit the content, you may wrap or truncate the content.
Cells that are likely to contain long strings may choose to wrap the content. This is the preferred way to accommodate long content because it doesn't hide the content.
Content truncation is available as a last resort when column widths are set. The full content may be exposed in a tooltip.
You may show a message to explain an absence of data. Just don't use a character like “x” or “-”. It creates a weird experience for assistive technologies like screen readers.
The placeholder should match the real content as closely as possible.Use the following properties to adjust the size and alignment of the placeholder:
Don't worry about whether the text wraps. Ideally, the height of the cell will not change once the data is loaded. However, it wouldn't be possible to know how many lines of text the content wraps to.
By paginating, the user can focus on segments of a large dataset without being overwhelmed. Pagination also helps with performance by reducing the amount of data to be downloaded and the amount of content that needs to be rendered.
If page length is too short, it would be annoying to browse the data in small segments. If page length is too long, users could get lost or overwhelmed.
The following factors influence what the ideal page length would be for your use-case:
These factors make it difficult to recommend an “ideal” page size for all use cases, but 20 rows is a good place to start.
Show a Blankslate
component in place of the table
Some strategies for adapting the table for narrow viewports include:
Use a data table for data in a flat hierarchical structure
Don't use a data table for information that has hierarchical relationships
Restrict the data in a column to represent one type of data
Don't group data in a column cell that isn't described by the column header
Leave the cell blank (preferred) or show text that explains the absence
Don't show a character, icon, or emoji to indicate a cell is empty
Allow the title in the page header to act as a table title when appropriate
Don't repeat or rephrase the title in the page header as the table title
Stretch to fill available space, and min width is the width of the widest cell in the column. This is the same behavior as a CSS grid column with the value minmax(auto, 1fr)
May have a min and max width constraint
Stretch to fill available space in the parent or shrink to fit in the available space in the parent
May have a min and max width constraint
The column is the width of its widest cell. Not intended for use with columns whose content length varies a lot because a layout shift will occur when the content changes.
May have a min and max width constraint
Will be exactly that width and will not grow or shrink to fill the parent
The action column would not accept a width. Its min-width would be the width of the actions.
If all columns have width constraints set and the row doesn't fill the table container, the difference is added to the width of the last column.
Options:
The column header starts unsorted. The first click sorts in ascending order, the second click sorts in descending order, and the third click removes the sort. When the sort is removed, the rows should be in the order they were in when the table was first rendered
A filter input is used to write a query and only show rows that match that query.
The table must have a title, and can optionally have a subtitle to describe more context. If you encounter a case where there is enough context that the table doesn’t need a visible label, you may hide it so it’s only accessible to assistive technologies.
If you use the table header, the table's title and subtitle will automatically be associated with the table for assistive technologies.
If your table's title exists somewhere else on the page (for example, in the PageHeader), then you must manually associate that contextual information with the table using ARIA.
The row header string will be prepended to the ARIA text of action buttons. For examples, Download {row header}“, “Actions:{row header}”
To handle cases where the row header can be very long, we should give consumers the option to specify a shorter string to identify the rows. For example, if an issue title is used as the row header, we could use the issue number instead of the full issue title.