Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Reorderable List

ProNew

Drag a handle to reorder: the row follows the pointer while the others slide aside with transforms, and the DOM changes once on drop.

Installation

pnpm dlx shadcn@latest add @viewport/reorderable-list

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above comes with Truffle Pro.

Props

PropTypeDefault
items*T[]—
getId*(item: T) => string

A stable id for each item.

—
getLabel*(item: T) => string

The item's name, used in announcements and on its drag handle.

—
onReorder*(items: T[]) => void

Receives the items in their new order.

—
renderItem*(item: T) => React.ReactNode

Draws the item's content. The drag handle is added before it.

—
label*string

Accessible name for the list.

—
classNamestring—
itemClassNamestring—

Accessibility

  • Every handle is a button named after its row.
  • Up and Down on a handle move the row, and the new position is announced.
  • Focus stays on the handle after a move.
  • Respects prefers-reduced-motion.