Skip to content

Reorder list

Pro

A 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

By name or description, across the 25 props below

ReorderList 18 props

  • childrentype ReactNodeRequired

    ReorderListItem elements, each with its own key.

  • disabledtype boolean

    No row takes a press or a key, while the app saves, say; the handles stay, disabled.

  • handlePlacementtype "start" | "end"default "start"

    Which side of the row the handle sits on.

  • moveMenutype booleandefault true

    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().

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

    Replaces the handle's drag_indicator.

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

    Replaces the move menu's arrow_upward, beside Move up.

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

    Replaces the move menu's arrow_downward, beside Move down.

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

    Replaces the move menu's vertical_align_top, beside Move to top.

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

    Replaces the move menu's vertical_align_bottom, beside Move to bottom.

  • reftype Ref<HTMLUListElement>

    Ref to the list.

  • idtype string

    The list's id.

Events

  • onReordertype (keys: string[], move: { key: string; from: number; to: number; }) => voidRequired

    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 key 7 comes back as "7"), wherever the row sits in arrays or fragments.

Text

  • labelstype Partial<ReorderListLabels>

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

  • aria-labeltype string

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

  • aria-labelledbytype string

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

ReorderListItem 7 props

  • textValuetype stringRequired

    The row's name, for its handle and what is said as it moves.

  • reorderabletype booleandefault true

    Whether it moves; a row that doesn't keeps its place and no row passes it.

  • childrentype ReactNode

    The row's content, beside the handle.

  • reftype Ref<HTMLLIElement>

    Ref to the row's element.

  • idtype string

    The row's id.

Hooks

useReorderListItem

useReorderListItem signature
useReorderListItem(): ReorderListItemActions

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

  • moveUptype () => voidRequired
  • moveDowntype () => voidRequired
  • moveToToptype () => voidRequired
  • moveToBottomtype () => voidRequired
  • canMoveUptype booleanRequired
  • canMoveDowntype booleanRequired

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.

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

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.

ReorderList tokens
VariableDefaultPaints
--wm-reorder-list-dragged-container-colorvar(--md-sys-color-tertiary-container)The dragged row’s container (Compose’s reorder item).
--wm-reorder-list-dragged-content-colorvar(--md-sys-color-on-tertiary-container)The dragged row’s text and icons.
--wm-reorder-list-dragged-elevationvar(--md-sys-elevation-level-4)The dragged row’s shadow: M3’s dragged list item, level 4.
--wm-reorder-list-dragged-cornervar(--md-sys-shape-corner-large)The dragged row’s corners.
--wm-reorder-list-item-cornervar(--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-colorvar(--md-sys-color-surface-container-low)Where the dragged row will land.
--wm-reorder-list-handle-size48pxThe 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-size24pxThe handle’s icon.
--wm-reorder-list-handle-colorvar(--md-sys-color-on-surface-variant)The handle’s icon colour.
--wm-reorder-list-item-gap8pxThe space between the handle and the row’s content.
--wm-reorder-list-item-gap-medium12pxThe same, in a list 600px wide or more.
--wm-reorder-list-item-padding-block8pxThe space above and below a row’s content.
--wm-reorder-list-lift-durationvar(--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-easingvar(--md-sys-motion-spring-effects-fast-easing)Its easing.
--wm-reorder-list-slide-durationvar(--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-easingvar(--md-sys-motion-spring-spatial-default-easing)Their easing.
--wm-reorder-list-settle-durationvar(--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-easingvar(--md-sys-motion-spring-spatial-fast-easing)Its easing.
--wm-reorder-list-scroll-edge48pxHow near a scroller’s (or the window’s) edge a dragged row starts to scroll it, faster nearer the edge.