Lists
Lists are continuous, vertical indexes of text or images.
Lists are a continuous group of text or images. They are composed of items containing primary and supplemental actions, which are represented by icons and text.
The last item of the previous demo shows how you can render a link:
<ListItemButton component="a" href="#simple-list">
<ListItemText primary="Spam" />
</ListItemButton>
You can find a demo with React Router following this section of the documentation.
Nested List
Interactive
Below is an interactive demo that lets you explore the visual results of the different settings:
Align list items
When displaying three lines or more, the avatar is not aligned at the top.
You should set the alignItems="flex-start"
prop to align the avatar at the top, following the Material Design guidelines:
List Controls
Checkbox
A checkbox can either be a primary action or a secondary action.
The checkbox is the primary action and the state indicator for the list item. The comment button is a secondary action and a separate target.
The checkbox is the secondary action for the list item and a separate target.
Sticky subheader
Upon scrolling, subheaders remain pinned to the top of the screen until pushed off screen by the next subheader. This feature relies on CSS sticky positioning. (⚠️ no IE 11 support)
Inset List Item
The inset
prop enables a list item that does not have a leading icon or avatar to align correctly with items that do.
Gutterless list
When rendering a list within a component that defines its own gutters, ListItem
gutters can be disabled with disableGutters
.
Virtualized List
In the following example, we demonstrate how to use react-window with the List
component.
It renders 200 rows and can easily handle more.
Virtualization helps with performance issues.
The use of react-window when possible is encouraged. If this library doesn't cover your use case, you should consider using react-virtualized, then alternatives like react-virtuoso.
Customization
Here are some examples of customizing the component. You can learn more about this in the overrides documentation page.
🎨 If you are looking for inspiration, you can check MUI Treasury's customization examples.