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';Props
List 35 props
ListItemelements, orListSections of them.The root element's id.
Flush items, or separate items 2px apart with rounded group corners.
Whether items can be selected: none, one or several.
The keys of the selected items (controlled).
The keys of the items selected at first (uncontrolled).
The last selected item can be deselected, leaving none.
falsekeeps at least one item selected.The keys of items that can't be pressed or selected.
The selected item of a radio list (Compose's single-selection
ListItem): withvalue,defaultValueoronChange, the list is a radio group whose items are radio buttons, each with avalue.The radio list's initially selected item value (uncontrolled).
The form field name of a radio list.
A radio list needs a choice before its form submits.
Disables every item.
Where a radio list's radio buttons sit, at the start or end of each row.
M3's dividers between items:
fullwidth, orinset16dp from each side. Standard lists only (segmented items are already apart). Left out, there are no dividers.Selected items show a check at their end besides their colour, so selection never relies on colour alone (M3 lists accessibility).
Web density,
0to-3(M3: a list "can adjust margins, spacing, or density"): each step takes 4px off every item (one line 56px at 0, 44px at -3; two lines 72 → 60px; three lines 88 → 76px; items grown by an image or avatar too) and off section subheaders, and the controls inside items follow. Left out, the list takes the density of the nearestThemeProviderorThemeScope. Prefer setting it there, from a setting, since M3 makes density the reader's choice.The expanded items of a list with
childItems(controlled).The items expanded at first (uncontrolled).
The most lines each item's headline shows, then "…". M3: one or two. Left out, no limit.
The most lines each item's supporting text shows, then "…". M3: one in a two-line item, two in a three-line item. Left out, no limit.
Where each item's handle sits, with
onReorder.Replaces the handle's
drag_indicatoricon, withonReorder.Ref to the root element: a
<ul>, or a<div>grid or listbox when interactive.
Events
Called when an item is pressed or Enter is pressed on it. Makes the list interactive.
Called with the selected keys when the selection changes.
Called with the chosen item's value when a radio list's selection changes.
Called with the expanded keys when an item expands or collapses.
Lets a person put the items in order (M3's dragged list item): each item gets a handle that drags it with a mouse, a finger or a pen (it follows the pointer and the items it passes slide aside) and, pressed, opens a menu (Move up, Move down, to the top, to the bottom), the way with the keyboard and without a drag. Called once a move lands, with every item's key in the new order; the order stays the app's, so render the items in it. Every move is said politely, focus stays with the moved item, and a disabled item keeps its place and lets none pass. The list is then a grid list (↑ / ↓ between items, ← / → to the handle); not with
childItems, sections or a radio list.
Text
Words a reorderable list says (the handle's name, its menu, what is said after a move), with English defaults. A
LabelsProvidersets them for the whole app.A row's handle, named after the row.
The move menu's item that moves the row one place up.
The move menu's item that moves the row one place down.
The move menu's item that moves the row to the top.
The move menu's item that moves the row to the bottom.
labels.movedtype(name: string, position: string, count: string) => stringdefault (name, position, count) =>${name} moved to position ${position} of ${count}Said after each move, the numbers in the page's language.
Said after a drag is cancelled.
Accessible name for the list (a list has no visible label of its own).
One of
aria-labeloraria-labelledbyis required.The id of the element that names the list, such as a heading above it.
One of
aria-labeloraria-labelledbyis required.
Classes for the root element, merged with
classNames.root; consumer classes win.Inline styles for the root element.
Classes for each part, by slot.
The root list element, merged with
className.Each
ListSection's wrapper (its subheader and items).Each
ListSection's subheader.Each item.
Each item's leading content (icon, avatar, media or control).
Each item's text column (overline, headline and supporting text).
Each item's overline.
Each item's headline.
Each item's supporting text.
Each item's trailing content.
The drawn switch, checkbox or radio button of an item that is one.
The check that marks a selected item in a list with
selectionMode.The chevron button that expands an item with nested items.
Every
ListItemImageandListItemVideoin the list (to round them, say).Each row's handle in a list with
onReorder(an icon button).The move menu a handle opens, its panel.
Also accepts the root element's HTML attributes (id, data-*, event handlers).
ListItem 27 props
The headline.
A short line above the headline.
One or two lines below the headline.
Leading content: an icon, an avatar, a
ListItemImageorListItemVideo, or a control.Trailing content: an icon, short text or a control (in an interactive list it gets focus with ← / →).
Makes the item a link. In a list without
onActionorselectionModethe item is a real<a>: its own Tab stop, with the browser's link menu and modified clicks, routed through aRouterProvider(such asNextRouterProvider) on a plain click.Marks the link item for the page being shown:
aria-current="page"and the selected colours.A link item's target;
_blankaddsrel="noopener noreferrer"unlessrelis given.A link item's
rel, e.g."nofollow".Downloads the link item's file instead of opening it (optionally with a file name).
Plain-text version of the headline, for type-ahead and announcements.
Makes the whole item a switch or a checkbox (Compose's toggleable
ListItem): pressing anywhere on it toggles it, and it is one control for assistive tech. Not in lists withonAction, links orselectionMode. Left out, the item is a plain row.Whether a switch or checkbox item is on (controlled).
Whether a switch or checkbox item starts on (uncontrolled).
Whether a switch, checkbox or radio item that's on takes the selected colours and shape (
secondary-container, 16px corners), as Compose's toggleable and selectableListItems do.falsekeeps it plain, with only its control showing the state, as a settings row. Either way the whole item stays the control: a press anywhere changes it, with the state layer and a pointer cursor.Where the switch, checkbox or radio button sits, at the start or end of the row.
A radio list item's value, or the value a switch or checkbox item posts with its form.
The form field name of a switch or checkbox item.
Disables the item.
Aligns the content; by default it is centred, and top-aligned in three-line items.
Shows ✓ and ✕ in a switch item's thumb.
The most lines the headline shows, then "…". Left out, the list's
headlineLinesapplies.The most lines the supporting text shows, then "…". Left out, the list's
supportingTextLinesapplies.childItemstypeReactElement<ListItemProps, string | JSXElementConstructor<any>> | ReactElement<ListItemProps, string | JSXElementConstructor<...>>[]Nested
ListItems (each with its ownkey): the item expands and collapses to show them, in a folder-like way (M3's expand interaction). It ends with a chevron, and → / ← expand and collapse it.
Events
Called when a switch or checkbox item is toggled.
ListSection 4 props
childrentypeReactElement<ListItemProps, string | JSXElementConstructor<any>> | ReactElement<ListItemProps, string | JSXElementConstructor<...>>[]RequiredListItemelements, each with its ownkey.The subheader shown above the section's items, which names the group.
One of
titleoraria-labelis required.
Text
Accessible name for the group, instead of the subheader's text.
One of
titleoraria-labelis required.
ListItemImage 10 props
What the image shows;
""when the headline already says it.The image. Without it, or when it fails to load,
fallbackshows.Image candidates for responsive loading, as
<img srcset>.The image's display sizes for
srcSet, as<img sizes>.Replaces the
<img>, such as a framework's image component; the frame still sizes it and crops it to fill.Shown with no
srcor when the image fails: an icon onsecondary-container.The frame's id.
Ref to the frame (
<span>).
Also accepts the root element's HTML attributes (id, data-*, event handlers).
ListItemVideo 13 props
What the image shows;
""when the headline already says it.The video's length, in its corner. In seconds, it shows as a clock in the locale's digits ("2:41", "1:02:03") and is read in words ("Length 2 minutes, 41 seconds"); a negative or unknown number shows nothing. A string is shown and read as written.
M3's small (
sm, 100 × 56dp) or large (lg, 114 × 64dp) thumbnail.The image. Without it, or when it fails to load,
fallbackshows.Image candidates for responsive loading, as
<img srcset>.The image's display sizes for
srcSet, as<img sizes>.Replaces the
<img>, such as a framework's image component; the frame still sizes it and crops it to fill.Shown with no
srcor when the image fails: an icon onsecondary-container.The frame's id.
Ref to the frame (
<span>).
Text
Words it says, with English defaults. A
LabelsProvidersets them for the whole app.
Also accepts the root element's HTML attributes (id, data-*, event handlers).
ListItemAvatar 9 props
The person's photo. Without it, or when it fails to load,
childrenshow.What the photo shows;
""(the default) when the headline names the person.Image candidates for responsive loading, as
<img srcset>.The image's display sizes for
srcSet, as<img sizes>.Initials or an icon, shown with no
srcor when the photo fails; hidden from assistive tech.The frame's id.
Ref to the frame (
<span>).
Also accepts the root element's HTML attributes (id, data-*, event handlers).
Tokens
M3's component tokens as CSS variables. Each is unset until you set it, on :root, a theme or any ancestor, and falls back to the default shown. The root carries data-variant (and data-size where it has sizes), which picks the variables that apply. See Component tokens in the Customisation guide.
| Variable | Default | Paints | Compose |
|---|---|---|---|
--md-comp-list-list-item-label-text-color | var(--md-sys-color-on-surface) | The headline. | ListTokens.ItemLabelTextColor |
--md-comp-list-list-item-supporting-text-color | var(--md-sys-color-on-surface-variant) | The supporting text. | ListTokens.ItemSupportingTextColor |
--md-comp-list-list-item-overline-color | var(--md-sys-color-on-surface-variant) | The overline. | ListTokens.ItemOverlineColor |
--md-comp-list-list-item-leading-icon-color | var(--md-sys-color-on-surface-variant) | The leading content: an icon, or text. | ListTokens.ItemLeadingIconColor |
--md-comp-list-list-item-trailing-icon-color | var(--md-sys-color-on-surface-variant) | The trailing content: an icon, or supporting text. | ListTokens.ItemTrailingIconColor |
--md-comp-list-list-item-selected-container-color | var(--md-sys-color-secondary-container) | A selected item. | ListTokens.ItemSelectedContainerColor |
--md-comp-list-list-item-selected-label-text-color | var(--md-sys-color-on-secondary-container) | A selected item's headline. | ListTokens.ItemSelectedLabelTextColor |
--md-comp-list-list-item-selected-supporting-text-color | var(--md-sys-color-on-secondary-container) | A selected item's supporting text. | ListTokens.ItemSelectedSupportingTextColor |
--md-comp-list-list-item-selected-overline-color | var(--md-sys-color-on-secondary-container) | A selected item's overline. | ListTokens.ItemSelectedOverlineColor |
--md-comp-list-list-item-selected-leading-icon-color | var(--md-sys-color-on-secondary-container) | A selected item's leading content. | ListTokens.ItemSelectedLeadingIconColor |
--md-comp-list-list-item-selected-trailing-icon-color | var(--md-sys-color-on-secondary-container) | A selected item's trailing content and its check. | ListTokens.ItemSelectedTrailingIconColor |
| Standard (variant) | |||
--md-comp-list-list-item-container-color | transparent | An item in a standard list: see-through, on its container's colour. | ListTokens.ItemContainerColor |
| Segmented (variant) | |||
--md-comp-list-list-item-segmented-container-color | var(--md-sys-color-surface) | An item in a segmented list. | ListTokens.ItemSegmentedContainerColor |
Hooks
useListItemReorder
Inside a reorderable List's item (its leading, trailing or headline content): the item's moves, for an app's own row menu (Move up and Move down beside its own actions). Focus stays where it is, the move is said, and the item stays in view.
Returns ListItemReorderActions
Moves the item up, down, to the top or to the bottom. Focus stays where it is.
Whether that move leads somewhere from where the item is.
Spec status
Built to the M3 Expressive list spec. Each item of its variants and configurations links to a live example; where the M3 Expressive column of the spec differs from the original M3 one, it wins.
| Item | Status | Details |
|---|---|---|
| Expressive list | Built | Variant · Static, Interactive |
| Style: standard | Built | Configuration · Dividers, Selection |
| Style: segmented | Built | Configuration · Static, Selection |
| Single-action list | Built | Configuration · Interactive, Links |
| Multi-action list | Built | Configuration · Interactive |
| Single-select list | Built | Configuration · Selection, Radio |
| Multi-select list | Built | Configuration · Selection, Toggles |
| Expand and collapse | Built | Configuration · Expandable |
| Images, video and avatars | Built | Use case · Media |
| Dividers and line limits | Built | Use case · Dividers |
| Density (web, chosen by the reader) | Built | Use case · Density |
| Standard item colour | Differs | Standard items are transparent rather than surface, so a list takes the colour of the sheet, card or pane it sits on. |
ListSection | Extension | M3 defines no list subheader: ListSection groups items under a title styled after the navigation drawer's section headline. Items take their corners within their section, and the arrow keys move across sections as through one list. |
| Baseline list | Not built | The spec recommends expressive lists instead; a standard list without selection gives the flush baseline look. |
| Swipe to reveal | Not built | The spec offers it on Android Views only. |
| Drag to reorder | Not built | Reordering and its dragged item state are deferred. |
Expressive list
BuiltVariant · Static, Interactive
Single-action list
BuiltConfiguration · Interactive, Links
Multi-action list
BuiltConfiguration · Interactive
Expand and collapse
BuiltConfiguration · Expandable
Images, video and avatars
BuiltUse case · Media
Dividers and line limits
BuiltUse case · Dividers
Density (web, chosen by the reader)
BuiltUse case · Density
Standard item colour
DiffersStandard items are transparent rather than
surface, so a list takes the colour of the sheet, card or pane it sits on.
ExtensionListSectionM3 defines no list subheader:
ListSectiongroups items under a title styled after the navigation drawer's section headline. Items take their corners within their section, and the arrow keys move across sections as through one list.Baseline list
Not builtThe spec recommends expressive lists instead; a standard list without selection gives the flush baseline look.
Swipe to reveal
Not builtThe spec offers it on Android Views only.
Drag to reorder
Not builtReordering and its dragged item state are deferred.
Bundle size
Gzipped, as published: the component and the library code it imports. React, React Aria, Motion and the other dependencies aren't counted, and your bundler's minifier makes it smaller still. CI fails a change that grows it past its budget.
List,ListItem,ListSection: 44.2 kBListItemImage,ListItemAvatar: 7.9 kBListItemVideo: 10.2 kB
M3 Expressive specs
- Variants
standard, segmented
Spec values and differences
- Heights follow Compose: at least 56px (one line), 72px (overline or supporting text) and 88px (both); three-line items align to the top, others to the centre.
- 16px padding at each side and 12px beside leading and trailing content, only when it's there: a text-only item's text spans 16px to 16px.
- Every
ListItemandSegmentedListItemoverload is covered: static items, clickable items (onAction, links), single selection (radio lists) and checkable items (switch and checkbox items). Selected items, chosen radio items and checked checkbox items take the selected colours and shape, as in Compose. - Deviation: a switch item that's on stays plain, as a settings row, with only its switch showing the state; Compose fills it as it fills a checked item.
selectedWhenCheckedgives it Compose's look, andselectedWhenChecked={false}keeps a checkbox or radio item plain. Theselected-*tokens set the colours. - Deviation: switch items have the switch role, so screen readers say on and off; Compose gives every checkable item the checkbox role, because Android lists have no switch role.
- Not included: long press (
onLongClick). On the web, an action needs a way in for every pointer and keyboard, so put it in a menu from a trailing icon button. - Shape precedence (pressed, then selected or focused at 16px, then hovered at 12px, else 4px) is computed into one
data-shapethat morphs on the fast spatial spring; segmented groups round their outer corners. - Deviation: standard items are transparent rather than Compose's
surface, so a list takes the colour of its sheet, card or pane. A dragged item is opaque: level 4, large (16px) corners, the 16% dragged state layer, andsurfacebehind a standard item (ItemContainerColor), as Compose's dragged list item. Not supported: swipe-to-reveal (Android only in M3).