Table
Table is a set of structured data that is easy for a user to scan, examine, and compare. Table data is displayed in a grid format and can be used to structure both interactive and static data.
Props
Usage guidelines
- Displaying a set of structured data in a scannable way, that populates 2 or more rows.
- Allowing users to compare information in rows and columns.
- There will never be enough data to populate at least 2 rows.
- Displaying content that doesn’t follow a consistent pattern and can't be broken down into columns.
- Providing robust data that doesn't fit in a tabular format. If there is a need to display a more complex data relationship, consider an info-graphic or a non-tabular format.
Best practices
Style
Use accessible Gestalt grays for table text, and reserve colors to sparingly accent important status and information. Avoid over-styling text.
Overuse color and styling for text in tables; it can make it hard to scan for important status updates and crucial information.
Alignment
Align content so that it’s easy to scan, read and compare:
- Start-align text and combo-content (combinations of text, numbers and/or graphics)
- End-align numbers only
- Align headers with their corresponding content
- Use tabular lining for numbers
Align content so that it makes it harder to scan, read, and compare.
- Center-align content
- Use proportional figures for numbers as they don’t quite align
- End-align text and combo-content (combinations of text, numbers and/or graphics)
- Misalign headers with their corresponding content
Place unit type on a separate column so that amounts can still align and be compared.
Mix text and graphics with numbers that need to be compared with each other.
Content
Make content digestible and scannable:
- Keep headers clear and concise
- Include an a visual indicator for cells that don’t have content.
- Give enough space for content to account for localization.
- Wrap important content to multiple lines
- Truncate secondary information, especially if a user is going to get the full content upon click of a link in the table.
Add so much content that it’s hard for a user to read, examine and scan:
- Don’t truncate content that a user needs to examine in relation to other content in the table.
- Leave cells blank so that it isn’t clear if all data has loaded.
Expand rows if the additional content is simple, doesn’t contain a lot of interaction and doesn’t take up more than 50% of the screen.
Use an expand to display dense, highly-interactive content. Use a new page or a Sheet for that.
Localization
Be sure to localize text
and accessibilityLabel
.
Note that localization can lengthen text by 20 to 30 percent; follow our guidelines on concise content and headings to account for localization.
Wrap important table content instead of truncating. Use truncation only for secondary content, and include a tooltip to show the full text on hover.
Accessibility
Labels
Use accessibilityLabel
to properly announce the content of the table. For example, use "Campaign Status Information".
Don’t include the word “table” as part of the label to prevent redundancy: the VoiceOver already appends “table” to the label and the Category “Table” in the rotor already describes the nature of the component.
In terms of structure and content, HTML tables already provide accessible ways to navigate content via cells <td>
and headers <th>
.
The Tab key should only place the focus on interactive elements like sortable headers, expands and links. If a cell does not contain interactive content, tabbing should skip the cell. Enter, Space and Return activate buttons and other controls after focusing. Arrow keys can be used to scroll table content vertically and horizontally.
Other considerations
Internally, Gestalt Table implements visually-hidden
captions through the accessibilityLabel
prop. Therefore, if we want to add visual captions (at the top or bottom of the Table), we must prevent redundancy. Any top or bottom text that describes the Table should be removed from navigation using aria-hidden
.
See the examples below for more details.
Subcomponents
Table.Header
Use Table.Header to group the header content in Table.
Table.Header Props
Table.Body
Use Table.Body to group the body content in Table.
Table.Body Props
Use Table.Footer to group the footer content in Table.
Table.Cell
Use Table.Cell for individual table values.
Table.Cell Props
Table.HeaderCell
Use Table.HeaderCell to define a header cell in Table.
Table.HeaderCell Props
Table.SortableHeaderCell
Use Table.SortableHeaderCell to define a header cell with sorting functionality in Table.
Table.SortableHeaderCell Props
Table.Row
Use Table.Row to define a row in Table.
Table.Row Props
Table.RowExpandable
Use Table.RowExpandable to define a row that expands and collapses additional content.
Table.RowExpandable Props
Variants
Sticky header
Sticky Column
Try scrolling horizontally to see the first column remain in place.
Multiple sticky columns
Try scrolling horizontally to see the first 3 columns remain in place.
Sticky header and sticky columns
Try scrolling horizontally and vertically to see the columns and header remain in place.
Table Row Expandable
Expandable row that is able to hold content that will displayed depending on the clickable expand/collapse button icon.
Table Row Expandable with Sticky Columns
When specifying stickyColumns
with expandable rows, include the column of arrows in your count. This example sets stickyColumns
to 3.
Sortable header cells
Sortable header cells are clickable in an accessible way and have an icon to display whether the table is currently being sorted by that column.
Sortable header cells with sticky columns
Component quality checklist
Quality item | Status | Status description |
---|---|---|
Figma Library | Partially ready | Component is live in Figma, however may not be available for all platforms. |
Responsive Web | Ready | Component is available in code for web and mobile web. |
iOS | Component is not currently available in code for iOS. | |
Android | Component is not currently available in code for Android. |
Related
Module
Modules are another way to stack multiple rows of content. However, they are used to show 2 to 3 blocks of related content, whereas Tables are used for large data sets that can be easily scanned and compared across multiple rows and columns.
Checkbox
Checkboxes are often used in tables to allow for selecting and editing of multiple rows at once.