Back to components
ElementData DisplayFree

Sortable List React component

A list people can put in their own order: drag a row by its handle and the others slide out of the way, or use the keyboard (Space to lift, arrows to move, Space to drop, Escape to undo), with live position numbers and optional remove buttons.

About the Sortable List component

Sortable List is a list of rows people reorder by dragging a handle. The row being moved lifts slightly and the others slide out of its way, numbers in front of the rows update as they move, and an optional remove button lets rows collapse away. It works with the keyboard and screen readers too: each move is announced.

items takes objects with id, title and an optional meta text on the right, like a time or a count. Pass items alone and the list keeps its own order, or pass value with onValueChange to control it. showNumbers shows the 1, 2, 3 in front of each row, removable adds the remove buttons and label names the list for assistive tech.

When to use it

Use Sortable List wherever order is the user's decision: agendas, playlists, priorities, menu items, form fields, steps in a flow. Dragging from the handle keeps the rest of the row free for scrolling on touch screens.

Save the new order from onValueChange; the component only reorders what you give it.

Installation

Add the Sortable List component to your project with the shadcn CLI. It lands in components/sortable-list.tsx as plain React + Tailwind CSS source you own and can edit.

Install
Copied!
npx shadcn@latest add @reactframe/sortable-list

Or copy the source by hand and install its dependencies:

Install
Copied!
npm install motion clsx tailwind-merge

More Data Display components

Organization Chart
Free
Data View
Free
Transfer List
Free
Icon Box
Free
Tree Table
Free
Icon List
Free