Skip to content

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

By name or description, across the 98 props below

List 35 props

  • childrentype ListChild | ListChild[]Required

    ListItem elements, or ListSections of them.

  • idtype string

    The root element's id.

  • varianttype "standard" | "segmented"default "standard"

    Flush items, or separate items 2px apart with rounded group corners.

  • selectionModetype "none" | "single" | "multiple"default "none"

    Whether items can be selected: none, one or several.

  • selectedKeystype "all" | Iterable<Key>

    The keys of the selected items (controlled).

  • defaultSelectedKeystype "all" | Iterable<Key>

    The keys of the items selected at first (uncontrolled).

  • deselectabletype booleandefault true

    The last selected item can be deselected, leaving none. false keeps at least one item selected.

  • disabledKeystype Iterable<Key>

    The keys of items that can't be pressed or selected.

  • valuetype string | null

    The selected item of a radio list (Compose's single-selection ListItem): with value, defaultValue or onChange, the list is a radio group whose items are radio buttons, each with a value.

  • defaultValuetype string

    The radio list's initially selected item value (uncontrolled).

  • nametype string

    The form field name of a radio list.

  • requiredtype booleandefault false

    A radio list needs a choice before its form submits.

  • disabledtype booleandefault false

    Disables every item.

  • controlPlacementtype "start" | "end"default "start"

    Where a radio list's radio buttons sit, at the start or end of each row.

  • dividerstype "full" | "inset"

    M3's dividers between items: full width, or inset 16dp from each side. Standard lists only (segmented items are already apart). Left out, there are no dividers.

  • selectionIndicatortype booleandefault true

    Selected items show a check at their end besides their colour, so selection never relies on colour alone (M3 lists accessibility).

  • densitytype 0 | -1 | -2 | -3default 0

    Web density, 0 to -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 nearest ThemeProvider or ThemeScope. Prefer setting it there, from a setting, since M3 makes density the reader's choice.

  • expandedKeystype Iterable<Key>

    The expanded items of a list with childItems (controlled).

  • defaultExpandedKeystype Iterable<Key>

    The items expanded at first (uncontrolled).

  • headlineLinestype 1 | 2 | 3

    The most lines each item's headline shows, then "…". M3: one or two. Left out, no limit.

  • supportingTextLinestype 1 | 2 | 3

    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.

  • reorderHandletype "leading" | "trailing"default "trailing"

    Where each item's handle sits, with onReorder.

  • dragHandleIcontype ReactElement<unknown, string | JSXElementConstructor<any>>

    Replaces the handle's drag_indicator icon, with onReorder.

  • reftype Ref<HTMLElement>

    Ref to the root element: a <ul>, or a <div> grid or listbox when interactive.

Events

  • onActiontype ((key: Key) => void)

    Called when an item is pressed or Enter is pressed on it. Makes the list interactive.

  • onSelectionChangetype ((keys: "all" | Set<Key>) => void)

    Called with the selected keys when the selection changes.

  • onChangetype ((value: string) => void)

    Called with the chosen item's value when a radio list's selection changes.

  • onExpandedChangetype ((keys: Set<Key>) => void)

    Called with the expanded keys when an item expands or collapses.

  • onReordertype ((keys: Key[], move: ReorderMove<Key>) => void)

    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

  • labelstype Partial<ListLabels>

    Words a reorderable list says (the handle's name, its menu, what is said after a move), with English defaults. A LabelsProvider sets them for the whole app.

  • aria-labeltype string

    Accessible name for the list (a list has no visible label of its own).

    One of aria-label or aria-labelledby is required.

  • aria-labelledbytype string

    The id of the element that names the list, such as a heading above it.

    One of aria-label or aria-labelledby is required.

Also accepts the root element's HTML attributes (id, data-*, event handlers).

ListItem 27 props

  • childrentype ReactNodeRequired

    The headline.

  • overlinetype ReactNode

    A short line above the headline.

  • supportingTexttype ReactNode

    One or two lines below the headline.

  • leadingtype ReactNode

    Leading content: an icon, an avatar, a ListItemImage or ListItemVideo, or a control.

  • trailingtype ReactNode

    Trailing content: an icon, short text or a control (in an interactive list it gets focus with ← / →).

  • hreftype string

    Makes the item a link. In a list without onAction or selectionMode the item is a real <a>: its own Tab stop, with the browser's link menu and modified clicks, routed through a RouterProvider (such as NextRouterProvider) on a plain click.

  • currenttype boolean

    Marks the link item for the page being shown: aria-current="page" and the selected colours.

  • targettype string

    A link item's target; _blank adds rel="noopener noreferrer" unless rel is given.

  • reltype string

    A link item's rel, e.g. "nofollow".

  • downloadtype string | boolean

    Downloads the link item's file instead of opening it (optionally with a file name).

  • textValuetype string

    Plain-text version of the headline, for type-ahead and announcements.

  • controltype "switch" | "checkbox"

    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 with onAction, links or selectionMode. Left out, the item is a plain row.

  • checkedtype boolean

    Whether a switch or checkbox item is on (controlled).

  • defaultCheckedtype boolean

    Whether a switch or checkbox item starts on (uncontrolled).

  • selectedWhenCheckedtype booleandefault false for a switch, true for a checkbox or a radio button

    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 selectable ListItems do. false keeps 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.

  • controlPlacementtype "start" | "end"default "start", or "end" for a switch

    Where the switch, checkbox or radio button sits, at the start or end of the row.

  • valuetype string

    A radio list item's value, or the value a switch or checkbox item posts with its form.

  • nametype string

    The form field name of a switch or checkbox item.

  • disabledtype booleandefault false

    Disables the item.

  • verticalAligntype "center" | "top"default "center", or "top" in three-line items

    Aligns the content; by default it is centred, and top-aligned in three-line items.

  • switchIconstype booleandefault false

    Shows ✓ and ✕ in a switch item's thumb.

  • headlineLinestype 1 | 2 | 3

    The most lines the headline shows, then "…". Left out, the list's headlineLines applies.

  • supportingTextLinestype 1 | 2 | 3

    The most lines the supporting text shows, then "…". Left out, the list's supportingTextLines applies.

  • childItemstype ReactElement<ListItemProps, string | JSXElementConstructor<any>> | ReactElement<ListItemProps, string | JSXElementConstructor<...>>[]

    Nested ListItems (each with its own key): 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

  • onCheckedChangetype ((checked: boolean) => void)

    Called when a switch or checkbox item is toggled.

Text

  • aria-labeltype string

    Accessible name when the headline isn't plain text.

ListSection 4 props

  • childrentype ReactElement<ListItemProps, string | JSXElementConstructor<any>> | ReactElement<ListItemProps, string | JSXElementConstructor<...>>[]Required

    ListItem elements, each with its own key.

  • titletype ReactNode

    The subheader shown above the section's items, which names the group.

    One of title or aria-label is required.

Text

  • aria-labeltype string

    Accessible name for the group, instead of the subheader's text.

    One of title or aria-label is required.

ListItemImage 10 props

  • alttype stringRequired

    What the image shows; "" when the headline already says it.

  • srctype string

    The image. Without it, or when it fails to load, fallback shows.

  • srcSettype string

    Image candidates for responsive loading, as <img srcset>.

  • sizestype string

    The image's display sizes for srcSet, as <img sizes>.

  • childrentype ReactNode

    Replaces the <img>, such as a framework's image component; the frame still sizes it and crops it to fill.

  • fallbacktype ReactNode

    Shown with no src or when the image fails: an icon on secondary-container.

  • idtype string

    The frame's id.

  • reftype Ref<HTMLSpanElement>

    Ref to the frame (<span>).

Also accepts the root element's HTML attributes (id, data-*, event handlers).

ListItemVideo 13 props

  • alttype stringRequired

    What the image shows; "" when the headline already says it.

  • durationtype string | number

    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.

  • sizetype "sm" | "lg"default "sm"

    M3's small (sm, 100 × 56dp) or large (lg, 114 × 64dp) thumbnail.

  • srctype string

    The image. Without it, or when it fails to load, fallback shows.

  • srcSettype string

    Image candidates for responsive loading, as <img srcset>.

  • sizestype string

    The image's display sizes for srcSet, as <img sizes>.

  • childrentype ReactNode

    Replaces the <img>, such as a framework's image component; the frame still sizes it and crops it to fill.

  • fallbacktype ReactNode

    Shown with no src or when the image fails: an icon on secondary-container.

  • idtype string

    The frame's id.

  • reftype Ref<HTMLSpanElement>

    Ref to the frame (<span>).

Text

  • labelstype Partial<ListItemVideoLabels>

    Words it says, with English defaults. A LabelsProvider sets them for the whole app.

Also accepts the root element's HTML attributes (id, data-*, event handlers).

ListItemAvatar 9 props

  • srctype string

    The person's photo. Without it, or when it fails to load, children show.

  • alttype string

    What the photo shows; "" (the default) when the headline names the person.

  • srcSettype string

    Image candidates for responsive loading, as <img srcset>.

  • sizestype string

    The image's display sizes for srcSet, as <img sizes>.

  • childrentype ReactNode

    Initials or an icon, shown with no src or when the photo fails; hidden from assistive tech.

  • idtype string

    The frame's id.

  • reftype Ref<HTMLSpanElement>

    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.

List tokens (md-comp-list)
VariableDefaultPaintsCompose
--md-comp-list-list-item-label-text-colorvar(--md-sys-color-on-surface)The headline.ListTokens.ItemLabelTextColor
--md-comp-list-list-item-supporting-text-colorvar(--md-sys-color-on-surface-variant)The supporting text.ListTokens.ItemSupportingTextColor
--md-comp-list-list-item-overline-colorvar(--md-sys-color-on-surface-variant)The overline.ListTokens.ItemOverlineColor
--md-comp-list-list-item-leading-icon-colorvar(--md-sys-color-on-surface-variant)The leading content: an icon, or text.ListTokens.ItemLeadingIconColor
--md-comp-list-list-item-trailing-icon-colorvar(--md-sys-color-on-surface-variant)The trailing content: an icon, or supporting text.ListTokens.ItemTrailingIconColor
--md-comp-list-list-item-selected-container-colorvar(--md-sys-color-secondary-container)A selected item.ListTokens.ItemSelectedContainerColor
--md-comp-list-list-item-selected-label-text-colorvar(--md-sys-color-on-secondary-container)A selected item's headline.ListTokens.ItemSelectedLabelTextColor
--md-comp-list-list-item-selected-supporting-text-colorvar(--md-sys-color-on-secondary-container)A selected item's supporting text.ListTokens.ItemSelectedSupportingTextColor
--md-comp-list-list-item-selected-overline-colorvar(--md-sys-color-on-secondary-container)A selected item's overline.ListTokens.ItemSelectedOverlineColor
--md-comp-list-list-item-selected-leading-icon-colorvar(--md-sys-color-on-secondary-container)A selected item's leading content.ListTokens.ItemSelectedLeadingIconColor
--md-comp-list-list-item-selected-trailing-icon-colorvar(--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-colortransparentAn item in a standard list: see-through, on its container's colour.ListTokens.ItemContainerColor
Segmented (variant)
--md-comp-list-list-item-segmented-container-colorvar(--md-sys-color-surface)An item in a segmented list.ListTokens.ItemSegmentedContainerColor

Hooks

useListItemReorder

useListItemReorder signature
useListItemReorder(): ListItemReorderActions

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

  • movetype (where: ReorderWhere) => voidRequired

    Moves the item up, down, to the top or to the bottom. Focus stays where it is.

  • canMovetype (where: ReorderWhere) => booleanRequired

    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.

  • 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.

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 kB
  • ListItemImage, ListItemAvatar: 7.9 kB
  • ListItemVideo: 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 ListItem and SegmentedListItem overload 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. selectedWhenChecked gives it Compose's look, and selectedWhenChecked={false} keeps a checkbox or radio item plain. The selected-* 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-shape that 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, and surface behind a standard item (ItemContainerColor), as Compose's dragged list item. Not supported: swipe-to-reveal (Android only in M3).