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';

Keyboard

List keyboard
KeyAction
TabMoves focus into the list and out of it. An interactive list or a radio list is one Tab stop; in a plain list each link, switch or checkbox item is its own Tab stop.
Arrow Down or Arrow UpMoves focus to the next or previous item, wrapping at the ends. In an interactive list a disabled item takes focus too, so screen reader users find it, but Enter, Space and a press do nothing on it.Interactive lists and plain lists of links
Home or EndMoves focus to the first or last item.Interactive lists and plain lists of links
EnterRuns onAction with the item's key, or follows a link item. In a selectable list it selects the item.Interactive lists and plain lists of links
SpaceSelects or deselects the focused option.With selectionMode
A letterMoves focus to the next item whose headline starts with the typed letters.Interactive lists
Arrow Right or Arrow LeftMoves focus between the item and a control in its trailing content, such as a switch.With onAction
Arrow Right or Arrow LeftExpands or collapses the focused item.Items with childItems
SpaceSwitches the item on or off.Switch and checkbox items
Arrow Down or Arrow UpMoves the choice to the next or previous item.Radio list
Arrow Right or Arrow LeftMoves focus between the item and its reorder handle (and the item's own controls).With onReorder
Enter or SpaceOpens the handle's menu: Move up, Move down, Move to top and Move to bottom, each disabled where it leads nowhere. Choosing one moves the item; focus comes back to the moved item, and the move is said.A reorder handle
EscapePuts back an item being dragged; nothing changes.While a reorder handle is dragged
  • Arrow keys move across sections as through one list.
  • In a plain list, each link stays a real anchor: the browser's link menu, status bar and new-tab clicks work, and a plain click goes through the app's router. Disabled link items have no link and are skipped.
  • In a reorderable list, Arrow Down and Arrow Up on a handle still move between items, as everywhere in a grid list; the handle's menu moves the item.

Screen reader

Role
A plain ul of li items. With onAction or onReorder, or links in a list that acts, a grid of rows; with selectionMode (and no onAction, onReorder or links) a listbox of options, as M3 asks on the web; with childItems a treegrid. A switch or checkbox item is a native checkbox (with role="switch" for a switch), and a radio list is a radiogroup of native radio buttons.
Accessible name
The list takes aria-label or aria-labelledby, which its types require. An item is named by its headline, and an option in a selectable list by all of its visible text (overline, headline, supporting and trailing text, in that order), so its name holds every word it shows and each is read once. Give a headline that isn't plain text a textValue, used for typeahead and announcements. A ListSection is named by its subheader (title), or its aria-label.
States announced
Selected (aria-selected) in a selectable list, disabled, expanded or collapsed (aria-expanded) with its level and position (aria-level, aria-posinset, aria-setsize) in a tree, aria-current="page" on a current link item, and on or off for a switch or checkbox item.
  • A switch or checkbox item is one control, named by its headline and described by its overline and supporting text.
  • A link item's link is its headline, with an overlay over the whole item, so buttons in its trailing content stay their own controls.
  • Selected items show a check as well as their colour, so selection never relies on colour alone; selectionIndicator={false} hides it.
  • Nested items that are closing are hidden from assistive tech and can't take focus.
  • A reorder handle is a button named "Reorder" and the item, which opens a menu (aria-haspopup). Every move, by a drag or the menu, is said politely ("Overture moved to position 2 of 5"), and so is a drag put back.

Focus

  • In an interactive list one item at a time is in the Tab order; the arrow keys move focus between items (roving focus). The expand chevron of a tree item is not a Tab stop: the item expands with the arrow keys or a press.
  • Keyboard focus shows M3's focus indicator inside the item, a 3px secondary outline drawn within its edges, since items are full-bleed; a focused item also takes its active corner shape. Pointer presses show no ring.
  • In a plain list only link, switch and checkbox items take focus. A radio list is one Tab stop, on the chosen item.

Touch target

  • Items are at least 56px tall (one line), 72px (two lines) or 88px (three lines), and as wide as the list.
  • The expand chevron of a tree item gets an invisible 48 × 48px TouchTarget.
  • A reorder handle is an extra-small icon button (32px, its 20px icon), so a one-line item keeps its 56px, with the icon button's 48 × 48px target. A finger on it drags at once, with no long press, and the page doesn't scroll under it.
  • With density (or the theme's), items lose 4px a step (one line 44px at -3). They're stacked rows, so each keeps a full-row target that never overlaps the next, above WCAG 2.5.8's 24px minimum, and the chevron's target is at most one row tall. M3 lets lists adjust their density; leave it to the reader's choice.

Motion

  • Under reduced motion the items of a reorderable list change place at once instead of sliding, and a dragged item still follows the pointer; its lift and drop only fade their shadow.
  • Under reduced motion nested items only fade in and out instead of also opening their height. When items open as others fold (an app keeping one item open), the folding ones go at once and the opening ones fade in, so the items below move once. The expand chevron flips without rotating. Item corners snap to their new shape, and the press ripple appears at full size without growing.
  • When a press opens an item while an open item above it folds, the item pressed stays where it is on screen, with or without reduced motion: the page scrolls by the folded height as the rows close, so nothing moves out from under the finger or pointer.

What you need to do

  • Name every list with aria-label, or aria-labelledby pointing at a visible heading.
  • Give an item whose headline isn't plain text a textValue; the list warns when one is missing.
  • Don't put buttons or links in the items of a selectable list (options can't hold them); use onAction for a list whose items hold controls, and give each trailing control its own name.
  • Keep switch and checkbox items in their own list, without onAction, links, selectionMode or childItems: a row can't be two controls, and the list throws an error. To pair an action with a switch, put a Switch in the item's trailing content.
  • With onReorder, render the items in the order it gives back, and give every item a plain-text headline or a textValue: it names the item's handle and what is said as it moves. Dragging is never the only way: the handle's menu moves an item with any pointer and the keyboard (WCAG 2.5.7), and useListItemReorder gives an item's own menu the same moves.