Reorder list
ProA vertical list whose rows a person puts in order: by dragging a handle, with the arrow keys, or from a move menu with no drag at all, each move said to screen readers. Not an M3 component (@windmorph/react-pro).
import { ReorderList, ReorderListItem, useReorderListItem } from '@windmorph/react-pro';Part of Windmorph Pro, paid components on the free core, not on sale yet. See the Pro guide for what it includes and to register interest.
Keyboard
| Key | Action |
|---|---|
| Tab or Shift + Tab | Moves to a row's handle, then the row's own controls. |
| Arrow Up or Arrow Down | On a handle: moves the row one place; focus stays on its handle. At an end nothing happens, quietly. |
| Home or End | On a handle: moves the row to the top or the bottom. |
| Enter or Space | On a handle: opens the move menu (Move up, Move down, Move to top, Move to bottom); nothing with moveMenu={false}. |
| Escape | While a pointer drags a row: puts it back. |
- The handle takes Up, Down, Home and End before its menu would, so they move the row; its description says so.
- Each handle is its own tab stop, so a screen reader's browse mode reaches every one.
Screen reader
- Role
- A
list(aulwithrole="list"), each row alistitem. The handle is a button; with the move menu it reportsaria-haspopup="menu"andaria-expanded. - Accessible name
- The list takes
aria-labeloraria-labelledby(one is required). Each handle is named from its row'stextValue("Reorder Simmer",labels.handle) and described as "Drag, or press the Up and Down arrow keys, to move it" (labels.handleDescription). - States announced
- Every move is said politely: "Simmer moved to position 2 of 5" (
labels.moved), each time for a key or a menu item, once on the drop for a drag, and "Simmer was put back" for a cancelled drag (labels.cancelled). Nothing on mount or for your own changes to the order.
- No
aria-grabbed,aria-dropeffectoraria-roledescription: the words say what happened. - A disabled list's handles are disabled buttons, out of the tab order.
- The announcements come from a live region mounted with the list, so the first one is read.
Focus
- After any move, focus is on the moved row's handle (or your own control in it, with
useReorderListItem()), and the row is brought into view no further than needed. Focus never falls to the page. - A row that leaves with focus in it hands focus to the row that took its place, else the one before, else the list.
- The handle shows the core icon button's focus ring on keyboard focus.
Touch target
- Each handle is a 48px round icon button; it follows density, 4px smaller a step and never under 24px.
- The move menu is the route without a drag (WCAG 2.5.7); keep it, or give every row a menu of its own.
Motion
- Rows making room slide on the default spatial spring; the lift fades its colour and shadow on the fast effects spring.
- Under reduced motion nothing slides: rows change places at once, and the lift's colour and shadow still fade.
What you need to do
- Name the list, and give each row a
textValuethat names it in the handle and the announcements. - Keep the order in state and give
onReorder's keys back; to refuse a move, give the old order back. - With
moveMenu={false}, put a menu on every row that moves it throughuseReorderListItem(). - Translate
labels(handle,handleTip,handleDescription,moveUp,moveDown,moveToTop,moveToBottom,moved,cancelled), or set them once for the app with aLabelsProvider. - In forced-colours mode the dragged row and the drop zone take a
CanvasTextborder.