Introduction
Tables display information in a way that’s easy to scan, so that users can look for patterns and insights. They can be embedded in primary content, such as cards. They can include functionality such as sorting, searching, pagination, and filtering.Basic Usage
Dense Table
A simple example of a dense table with no frills.Sorting & Selecting
This example demonstrates the use of Checkbox and clickable rows for selection, with a custom Toolbar.Sticky Header
Here is an example of a table with scrollable rows and fixed column headers.Column Grouping
You can group table headers by rendering multiple table rows inside a table head.Collapsible Table
An example of a table with expandable rows.Props
Table Props
| Prop | Type | Default | Description |
|---|---|---|---|
children | node | - | The content of the table, normally TableHead and TableBody. |
classes | object | - | Override or extend the styles applied to the component. |
padding | 'normal' | 'checkbox' | 'none' | 'normal' | Allows TableCells to inherit padding of the Table. |
size | 'small' | 'medium' | 'medium' | Allows TableCells to inherit size of the Table. |
stickyHeader | boolean | false | Set the header sticky. |
sx | SxProps<Theme> | - | The system prop for defining CSS overrides and additional styles. |
TableCell Props
| Prop | Type | Default | Description |
|---|---|---|---|
align | 'inherit' | 'left' | 'center' | 'right' | 'justify' | 'inherit' | Set the text-align on the table cell content. |
children | node | - | The content of the component. |
classes | object | - | Override or extend the styles applied to the component. |
padding | 'normal' | 'checkbox' | 'none' | - | Sets the padding applied to the cell. Inherits from parent Table. |
scope | string | - | Set scope attribute. |
size | 'small' | 'medium' | - | Specify the size of the cell. Inherits from parent Table. |
sortDirection | 'asc' | 'desc' | false | - | Set aria-sort direction. |
sx | SxProps<Theme> | - | The system prop for defining CSS overrides and additional styles. |
variant | 'head' | 'body' | 'footer' | - | Specify the cell type. Inherits from parent context. |
TableRow Props
| Prop | Type | Default | Description |
|---|---|---|---|
children | node | - | Should be valid tr children such as TableCell. |
classes | object | - | Override or extend the styles applied to the component. |
hover | boolean | false | If true, the table row will shade on hover. |
selected | boolean | false | If true, the table row will have the selected shading. |
sx | SxProps<Theme> | - | The system prop for defining CSS overrides and additional styles. |
CSS Classes
Table Classes
.MuiTable-root- Styles applied to the root element..MuiTable-stickyHeader- Styles applied to the root element ifstickyHeader={true}.
TableCell Classes
.MuiTableCell-root- Styles applied to the root element..MuiTableCell-head- Styles applied to the root element ifvariant="head"..MuiTableCell-body- Styles applied to the root element ifvariant="body"..MuiTableCell-footer- Styles applied to the root element ifvariant="footer"..MuiTableCell-alignLeft- Styles applied to the root element ifalign="left"..MuiTableCell-alignCenter- Styles applied to the root element ifalign="center"..MuiTableCell-alignRight- Styles applied to the root element ifalign="right"..MuiTableCell-alignJustify- Styles applied to the root element ifalign="justify"..MuiTableCell-sizeSmall- Styles applied to the root element ifsize="small"..MuiTableCell-paddingCheckbox- Styles applied to the root element ifpadding="checkbox"..MuiTableCell-paddingNone- Styles applied to the root element ifpadding="none"..MuiTableCell-stickyHeader- Styles applied to the root element if table hasstickyHeader={true}.
TableRow Classes
.MuiTableRow-root- Styles applied to the root element..MuiTableRow-selected- Styles applied to the root element ifselected={true}..MuiTableRow-hover- Styles applied to the root element ifhover={true}..MuiTableRow-head- Styles applied to the root element if table variant is head..MuiTableRow-footer- Styles applied to the root element if table variant is footer.
Accessibility
Caption
A caption functions like a heading for a table. UseTableContainer with appropriate labeling:
Sortable Tables
When implementing sortable columns, useTableSortLabel and provide screen reader announcements: