Sortable List
A list you reorder by dragging its handles or with the keyboard, with every move undoable.
- Category
- Data & feedback
- Access
- Free with an account
- Source
- 231 lines · one file
- States
- 5 drawn
- Added
- 3 Nov 2026
The decision inside it
Only the handle drags, and the keyboard gets the same power
Text in a row stays selectable and a finger scrolling the page never starts a drag. Keyboard users can reorder too, and a screen reader hears each step: picked up, moved to 4 of 6, dropped.
When to use it
Use Sortable List when people set an order themselves: steps, priorities, menu items, a playlist. For moving cards between columns use Kanban Board.
Installation
How you get it
Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.
Use Liro's Sortable List for this.
Install it: npx shadcn@latest add @liro/sortable-list
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
Import it from @/components/ui/sortable-list.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Free components install through the @liro registry with your CLI token: see the Namespaced tab.
Usage
"use client";
import { useState } from "react";
import { SortableList } from "@/components/ui/sortable-list";
type Task = { id: string; title: string };
export function PriorityList({ initial }: { initial: Task[] }) {
const [tasks, setTasks] = useState(initial);
return (
<SortableList
label="Priorities"
items={tasks}
getKey={(t) => t.id}
getLabel={(t) => t.title}
onReorder={setTasks}
renderItem={(t, { index }) => <span>{index + 1}. {t.title}</span>}
/>
);
}API reference
“Copy prompt” above puts a full brief on your clipboard, install command, dependencies, props, and the mistakes an assistant usually makes with this component.
Props
Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.
| Type | Notes | ||
|---|---|---|---|
items | T[] | Yes | – |
getKey | (item: T) => string | Yes | – |
getLabel | (item: T) => string | Yes | The row's name, for announcements and the undo bar. |
onReorder | (items: T[]) => void | Yes | – |
renderItem | (item: T, state: { index: number; lifted: boolean }) => React.ReactNode | Yes | – |
undoFor | number | No | How long the Undo bar stays, in ms. Default 6000. |
label | string | No | A name for the list, for screen readers. |
Dependencies
npm packages
clsxframer-motionlucide-reacttailwind-mergeLiro foundations, installed alongside it
liro-themeStates
All of them are drawn by the component. None is left for you to design.
- Idle
- Dragging
- Picked up (keyboard)
- Moved
- Undo
Accessibility
- Keyboard reachable throughout, in visual order
- Focus trapped in overlays, Escape closes them
- Focus returns to whatever opened it
- Live regions announce what changed, not that something did
- Honours prefers-reduced-motion
Responsive behavior
- Sizes to its container, not the viewport
- Usable from 320px up
- Pointer-based interaction, so trackpad and touch both work
- No hover-only affordances