Lists

Lists are continuous, vertical indexes of text or images.

The List component is composed of items containing primary and supplemental actions, which are represented by icons and text. Lists are optimized for reading comprehension. A list consists of a single continuous column of subdivisions called rows that contain items of content.

Basic List

A List is a wrapper for multiple ListItem elements which can behave as text, links, or buttons.

In a simple navigational scenario, define ListItems as links be either:

  1. Including a href prop
  2. Including the link prop and passing a custom link component, such as from a routing library

This will allow the a to inherit the ListItem default styling. For more complex design patterns, do not supply the href or link props, and wrap ListItem children with custom components as needed.

List with Avatar Icons

This example illustrates using ListItemAvatar and Avatar to contain an icon, the secondary ListItemText prop, and use of selected on ListItem to highlight a current item.

List with Avatar and Multi-line Secondary Content

Data Lists

The datalist property is a structural variant for <List/> that offers three layouts intended for non-table key/value pairs.

Using datalist limits the allowed <List/> children to only <ListText> and it is expected that both a primary and secondary value are provided, where primary becomes the "key" and secondary becomes the "value".

String content or React elements can be provided to the primary or secondary prop, as is also valid in regular Lists. This allows flexibility in formatting as well as allowing icons or extra actions to be provided. Be aware that adding non-text content may create a need to resolve for any alignment side effects.

Vertical (default)

Keys and values stay in row alignment until the container width is reduced below the computed or supplied datalistBreakpoint and then the value drops below the key into stacked alignment.

Additional Properties

The following are valid only for the vertical layout.

dataKeyWidth

Value: numerical, intended to be max-allowed character width for the key.

If not passed, this is computed by looping through all list items and finding the longest key by character count.

datalistBreakpoint

Value: string, recommended to be set in rem

Determines at what total list width to break the value below the key.

If not passed, this is set to 20rem as default unless the dataKeyWidth is passed or computed to be greater than 16, in which case this is recomputed to allow more space to prevent the value column becoming far too narrow before breaking.

Horizontal

Values are right aligned and never wrap below the key.

Columns

Multi-column layout is applied when the container width allows, switching to stacked layout with similar appearance to vertical within narrow containers/mobile views.

Properties