Skip to content
Thrum

Sortable list

A short list the reader puts in order: priorities, steps, columns to show. Each item has a handle to drag, with a mouse, a finger or the keyboard. For moving items between two lists use the transfer list; for thousands of rows, order them with a sort instead.

Install

npx shadcn@latest add @thrum-pro/sortable-list

This is a Pro component. The command works once your project has a licence key: set up Pro or see pricing.

Automatically installs icon grip-vertical from the icon set.

Data shape

Type
type SortableItem = {
  id: string;
  label: string;
  description?: string;
  disabled?: boolean;
};
Sample
const items: SortableItem[] = [
  { id: "notes", label: "Draft the release notes", description: "Due Friday" },
  { id: "contract", label: "Review the Northwind contract" },
  { id: "export", label: "Fix the export timeout", disabled: true },
];

Props

PropTypeDefaultDescription
itemsreadonly SortableItem[]RequiredThe items. Their order here is the order at first, unless order or defaultOrder sets another.
orderreadonly string[]–The ids in order, when the parent holds the order. Use it with onReorder. Ids it leaves out follow, in the order of items.
defaultOrderreadonly string[]–The ids in order at first, when the list holds the order itself.
onReorder(ids: string[]) => void–Called with every id in the new order when an item is dropped somewhere new. Not called while it moves, nor when it lands where it started.
axis"x" | "y"Default "y"y stacks the items, x sets them in a row that scrolls sideways when it is too long.
aria-labelstring–The list's name. Or point aria-labelledby at a visible heading.
soundbooleanDefault truePlay lift, tick and drop sounds while an item moves, if the visitor has sound on.
classNamestring–Extra classes for the list, merged last.

Motion and sound

Motion

  • While an item moves, the others slide aside with a quick spring that settles without overshoot.
  • A lifted item gains a shadow and a ring-coloured border over 150 ms. A dragged item follows the pointer and settles into its slot when dropped.
  • Reduced motion: the other items jump to their places, and a dropped item lands at once.

Sound

  • Lift when an item is picked up, a tick each time it passes another, and drop when it is set down or the move is cancelled.

Sound is off until the visitor turns it on. Pass sound={false} to keep this component silent. How sound works

Accessibility

  • It is a list of list items. Each handle is a button named Move and the item's label, described by the keyboard instructions, and pressed while the item is lifted.
  • Every lift, move, drop and cancel is read out by an assertive live line, such as Draft the release notes, position 3 of 5.
  • A lifted item is marked by aria-pressed on its handle, a ring-coloured border and a shadow, so the state does not rest on colour.
  • Only the handle starts a drag and it does not scroll the page, so the rest of a row still scrolls on a phone. The handle is 32 pixels square.
  • A disabled item says so on its handle and cannot be lifted; the others can still move past it.
  • Long labels wrap. Nothing overflows at 160 pixels wide.
KeysAction
TabMove from one item's handle to the next.
Space / EnterLift the item; press again to drop it where it is.
↑ / ↓Move the lifted item one place up or down. In a row, ← and → do it.
Home / EndMove the lifted item to the start or the end.
EscPut the lifted item back where it was. Moving the focus away does the same.

Source

SourcePro

The source comes with Pro

TypeScript source · Copy-paste ready · MIT-compatible for client projects · Includes all dependencies

Files and dependencies

Adds
components/ui/sortable-list.tsx
Packages
motion
Brings along
Motion tokensSound engine
Icons
grip-vertical

Changelog

  1. 1.0.0 · 2026-12-03First release.

Loading index…

Keyboard shortcuts

/Ctrl KSearch components, docs and actions
?Show this list
AAppearance studio
SSound on or off
MFull or reduced motion
TTheme: auto, light, dark
GSurface: solid or frosted
BBackdrop photograph (under glass)
CCorner radius: square to round
RReplay the demo, on a component page
DDraw new data, on a component page
←→HomeEndMove the cursor in a focused chart
EscClose a dialog, or leave a chart cursor