Overview
Reference usage
Drag-and-drop reorderable list that emits the new order on each change.
Usage
Move buttons
Dragging needs a pointer that can hold and move, so a list that people reorder should offer a single-pointer alternative (WCAG 2.5.7). Set reorderMode="buttons" to give each row Move up and Move down buttons in place of the drag handle, or reorderMode="both" to keep the handle and add them. The row's context then carries a moveButtons snippet; render it where the buttons belong, beside the row's own controls. The first row has no Move up, the last no Move down, and a lone row has neither. Pressing a button reorders through onReorder with the same change descriptor a drop gives, announces the move, and keeps focus on the pressed button, or on the row's other button when the pressed one no longer applies. formatMoveUpLabel and formatMoveDownLabel rename the buttons ("Move Ask an agent up").
- Press Space to lift, then arrow keys to move, Space to drop, Escape to cancel.
- Write release notes
- Review pull requests
- Update dependencies
- Deploy to staging
When to use
- Letting users manually reorder a small to medium list of items via drag handle or keyboard.
- Surfacing live region announcements during a reorder for accessible feedback.
- Showing a read-only list with no reorder affordance — use grid-list instead.
- Sorting by a column or computed key — sort the source array and rerender.
Examples
Basic sortable list
Keyboard and pointer reorderable list with announcer feedback.
Props
Name | Type | Default | Description |
|---|---|---|---|
items required | Item[] | The list of items to render. | |
getKey required | (item: Item) => stringnumber | Returns a stable key for each item. Must not change across reorders. | |
getItemLabel required | (item: Item, originalIndex: number) => string | Returns an accessible label for each item (e.g., "Buy milk").
The second argument is the item's original index in the items array
(not its current visual position during a drag).
Used in handle aria-label and announcements. | |
formatHandleLabel | (itemLabel: string) => string | Optional formatter for the drag handle's accessible name. Default: "Reorder {itemLabel}". | |
reorderMode | 'handle' | 'buttons' | 'both' | 'handle' | How a row is reordered; see SortableReorderMode. With buttons or both the row's context
carries a moveButtons snippet, which the row content renders where the buttons belong. |
formatMoveUpLabel | (itemLabel: string) => string | Optional formatter for the Move up button's accessible name. Default: "Move {itemLabel} up". | |
formatMoveDownLabel | (itemLabel: string) => string | Optional formatter for the Move down button's accessible name. Default: "Move {itemLabel} down". | |
handle | snippet | Optional snippet rendered inside the drag-handle button. Receives { pressed, label }. | |
onReorder required | (nextItems: Item[], change: import('../../utilities/sortable-controller.types.ts').SortableReorderChange, ) => void | Fires with the full reordered array and change metadata on drop. | |
announcements | Partial<import('../../utilities/sortable-controller.types.ts').SortableAnnouncements > | Optional overrides for announcement strings. | |
children required | snippet | Row content snippet. Receives the item and a per-row context. | |
label | text | Accessible name for the list (applied as aria-label on the list root). |