List
Rows with headline, overline, supporting text and leading or trailing content (icons, avatars, images, video thumbnails); items can be links, switches, checkboxes or radio buttons, and put in order by drag or a menu.
import { List, ListItem, ListSection, ListItemImage, ListItemVideo, ListItemAvatar, useListItemReorder } from '@windmorph/react';Purpose
A list presents a vertical set of items, each with a headline and optional overline, supporting text and leading or trailing content. Use it for rows that stay visible; for a temporary set of choices anchored to a button use a Menu.
List holds ListItem children identified by a React key. The variant is standard (flush) or segmented (rounded groups 2px apart). ListSection groups items, under a subheader when it has a title, in static, interactive and selection lists, but not in radio lists or lists with nested items.
Images, video, lines and dividers
ListItemImageinleadingis M3's 56dp image, cropped to fill. Passsrc,srcSetandsizes, or your framework's image as its child.fallback(an icon) shows with no image or when it fails to load.ListItemVideois a video's thumbnail, 100 × 56dp (size="lg": 114 × 64dp), with a play badge and itsduration. Pressing it is pressing the item.- Images and videos have 8dp corners (M3 Expressive). Change them with the list's
classNames.mediaor their ownclassName.ListItemAvataris M3's 40dp avatar: a photo, or initials onprimary-container. Icons in the leading and trailing content are 20dp. headlineLinesandsupportingTextLines(1 to 3), on the list or an item, end long text with "…"; the full text stays in the accessible name. M3's limits are one line of supporting text in a two-line item and two in a three-line item. There are no limits by default.dividers="full"or"inset"(16dp from each side) draws M3's dividers between items of a standard list. Segmented items are already apart, so they don't take dividers.
Putting items in order
onReordergives each item a handle. Dragged with a mouse, a finger or a pen, the item follows the pointer and the items it passes slide out of its way; it lands where it's dropped, and Escape puts it back. Pressed, the handle opens a menu: Move up, Move down, Move to top, Move to bottom, the way with the keyboard and without a drag.onReorder(keys, move)is called once a move lands, with every key in the new order. The order is yours: render the items in it, and save it.- The handle sits at the end of each item (
reorderHandle:"leading"puts it first);dragHandleIconreplaces its icon. A disabled item keeps its place and no item passes it, and a list of one item has no handle. - For an item's own menu (Move up and Move down beside its other actions), call
useListItemReorder()inside its content formoveandcanMove. - A reorderable list is a grid list, selection included; it can't hold sections or nested items, or be a radio list. For rows of your own content rather than list items, Windmorph Pro has the Reorder list, on the same engine.
Which list
- Items that go to other pages (a settings menu, legal pages): link items (
href, withcurrenton the page being shown), in a list withoutonAction. - An on/off setting that applies at once: a switch item (
control="switch"), which stays plain when it's on. Choosing several items: checkbox items (control="checkbox"), which take the selected colours when checked. - One choice out of a few, applied at once: a radio list (
value/onChange, each item with avalue). - An item that opens something and also has its own switch: an interactive list with a
Switchin the item's trailing content. - Many options, or choices inside a form with a submit button:
RadioGroup,CheckboxorSwitchon their own.
When not to use
For top-level navigation use a Navigation rail or bar; for tabular data use a table.
See also
- List on m3.material.io: Material's own guidelines, with anatomy and specs.
- Card: A container for related content in three forms: static, pressable or a link.
- Menu: A temporary list of choices anchored to a trigger, with groups, selection, submenus and context menus, or a bottom sheet on phones.