uimaxxer

Reorder list

Grab a handle and the row lifts out of its tray while the others part to make room. Near an edge the list scrolls for you, and the keyboard can do it all with spoken positions.

npx shadcn@latest add @uimaxxer/reorder-list
Pro
PasskeysRun order

Run order

Run order

7 tasks, $2.43, 43 min

  • Reproduce the flaky billing webhook test+0:00
  • Patch retry logic in webhooks/stripe.ts+0:04
  • Write regression tests for duplicate events+0:13
  • Run the full suite on staging+0:20
  • Update the incident note in docs/incidents+0:32
  • Open the pull request for review+0:34
  • Move invoice PDFs to the new bucket+0:35

Press Space to pick up. Use the arrow keys to move, Space to drop and Escape to cancel.

Usage

import { ReorderList } from "@/components/ui/reorder-list"

<ReorderList
  aria-label="Run order"
  items={tasks}
  onReorder={setTasks}
  getLabel={(t) => t.title}
  renderItem={(t) => <span>{t.title}</span>}
/>

Props

PropTypeDefaultWhat it does
itemsT[] (each with an id)Controlled order.
defaultItemsT[]Initial order when uncontrolled.
onReorder(items: T[]) => voidCalled with the new order on drop, and on each keyboard move.
renderItem(item: T, index: number) => ReactNodeThe row's content, beside the handle.
getLabel(item: T) => stringPlain text for the handle's name and the announcements.
aria-labelstringNames the list.
maxHeightnumberScroll inside the tray past this height; dragging near an edge auto-scrolls.

Keyboard

Space / Enter
Pick up or drop
↑ ↓
Move the picked-up row
Home / End
Move it to the top or bottom
Escape
Put it back where it started

Accessibility

  • Each handle is a button named for its row, with aria-pressed while picked up and instructions in aria-describedby.
  • Pick-up, every move, drop and cancel are announced with the position, for example 'position 3 of 7'.
  • Only the handle starts a drag, so the row's own text and links still work with touch.