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.
Props
ReorderList 18 props
ReorderListItemelements, each with its ownkey.No row takes a press or a key, while the app saves, say; the handles stay, disabled.
Which side of the row the handle sits on.
The handle opens a menu (Move up, Move down, to the top, to the bottom): the way to move without a drag (WCAG 2.5.7). Turn it off only where every row's own menu has the same moves, through
useReorderListItem().Replaces the handle's
drag_indicator.Replaces the move menu's
arrow_upward, beside Move up.Replaces the move menu's
arrow_downward, beside Move down.Replaces the move menu's
vertical_align_top, beside Move to top.Replaces the move menu's
vertical_align_bottom, beside Move to bottom.Ref to the list.
The list's id.
Events
Called once a move lands (a drop, a key or a menu item), with every row's key in the new order: each row's own
key, as React holds it (a string; a number key7comes back as"7"), wherever the row sits in arrays or fragments.
Text
Words the list says, with English defaults. A
LabelsProvidersets them for the whole app.The handle's name.
The handle's tooltip.
How the handle is used, its description.
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.
Said after a drag is cancelled.
One of
aria-labeloraria-labelledbyis required.One of
aria-labeloraria-labelledbyis required.
Classes for the list. Wins over the defaults via
cn().Classes for each part.
Inline styles for the list, e.g.
--wm-reorder-list-*tokens.
ReorderListItem 7 props
The row's name, for its handle and what is said as it moves.
Whether it moves; a row that doesn't keeps its place and no row passes it.
The row's content, beside the handle.
Ref to the row's element.
The row's id.
Hooks
useReorderListItem
Inside a ReorderListItem: its moves, for an app's own row menu (Move up and Move down beside the app's own items). Focus stays where it is; the moved row stays in view.
Returns ReorderListItemActions
Spec status
Not part of Material Design 3: a Windmorph Pro component, built on M3's colour roles, type scale, shapes and motion. Its variants and configurations each link to a live example.
| Item | Status | Details |
|---|---|---|
| Moving a row by dragging its handle, by the keys and from the move menu | Built | Use case · Steps |
A row's own menu moving it (moveMenu={false}, useReorderListItem) | Built | Configuration · Own menu |
A row that keeps its place (reorderable={false}) | Built | Configuration · Own menu |
The handle at the end (handlePlacement="end") | Built | Configuration · Own menu |
| M3’s dragged item | Extension | The lifted row takes the dragged list item of M3’s Compose tokens: tertiary-container with on-tertiary-container, level 4 elevation and 16px corners, over a drop zone in surface-container-low. |
| Moving without a drag | Extension | Arrow keys, Home and End on the handle and its move menu move a row too, and every move is announced (WCAG 2.5.7, 4.1.3). |
Moving a row by dragging its handle, by the keys and from the move menu
BuiltUse case · Steps
A row's own menu moving it (
BuiltmoveMenu={false},useReorderListItem)Configuration · Own menu
A row that keeps its place (
Builtreorderable={false})Configuration · Own menu
The handle at the end (
BuilthandlePlacement="end")Configuration · Own menu
M3’s dragged item
ExtensionThe lifted row takes the dragged list item of M3’s Compose tokens:
tertiary-containerwithon-tertiary-container, level 4 elevation and 16px corners, over a drop zone insurface-container-low.Moving without a drag
ExtensionArrow keys, Home and End on the handle and its move menu move a row too, and every move is announced (WCAG 2.5.7, 4.1.3).
Theming & tokens
Set the tokens below on the list or any ancestor: the dragged row's colours, elevation and corner, the drop zone, the handle's size, icon and colour, the auto-scroll edge and the motion. The handle is a 48px round core IconButton that follows density, and the move menu the core Menu, themed by their own tokens. className and aria-* go on the list; style each part with classNames: root, item, handle, content, dropZone, menu.
| Variable | Default | Paints |
|---|---|---|
--wm-reorder-list-dragged-container-color | var(--md-sys-color-tertiary-container) | The dragged row’s container (Compose’s reorder item). |
--wm-reorder-list-dragged-content-color | var(--md-sys-color-on-tertiary-container) | The dragged row’s text and icons. |
--wm-reorder-list-dragged-elevation | var(--md-sys-elevation-level-4) | The dragged row’s shadow: M3’s dragged list item, level 4. |
--wm-reorder-list-dragged-corner | var(--md-sys-shape-corner-large) | The dragged row’s corners. |
--wm-reorder-list-item-corner | var(--md-sys-shape-corner-large) | A row’s corners at rest (seen on its state layer and in forced colours). |
--wm-reorder-list-drop-zone-color | var(--md-sys-color-surface-container-low) | Where the dragged row will land. |
--wm-reorder-list-handle-size | 48px | The handle’s width and height, fully round; each density step takes 4px off, never under 24px. A row without a handle keeps its column. |
--wm-reorder-list-handle-icon-size | 24px | The handle’s icon. |
--wm-reorder-list-handle-color | var(--md-sys-color-on-surface-variant) | The handle’s icon colour. |
--wm-reorder-list-item-gap | 8px | The space between the handle and the row’s content. |
--wm-reorder-list-item-gap-medium | 12px | The same, in a list 600px wide or more. |
--wm-reorder-list-item-padding-block | 8px | The space above and below a row’s content. |
--wm-reorder-list-lift-duration | var(--md-sys-motion-spring-effects-fast-duration) | How long the lifted look takes to come and go (kept under reduced motion: a fade). |
--wm-reorder-list-lift-easing | var(--md-sys-motion-spring-effects-fast-easing) | Its easing. |
--wm-reorder-list-slide-duration | var(--md-sys-motion-spring-spatial-default-duration) | How long rows take to slide out of the way and into new places (at once under reduced motion). |
--wm-reorder-list-slide-easing | var(--md-sys-motion-spring-spatial-default-easing) | Their easing. |
--wm-reorder-list-settle-duration | var(--md-sys-motion-spring-spatial-fast-duration) | How long a dropped (or put back) row takes to settle into its place (at once under reduced motion). |
--wm-reorder-list-settle-easing | var(--md-sys-motion-spring-spatial-fast-easing) | Its easing. |
--wm-reorder-list-scroll-edge | 48px | How near a scroller’s (or the window’s) edge a dragged row starts to scroll it, faster nearer the edge. |