Components

Sortable List

A drag-and-drop sortable list for React built on Motion's Reorder and Tailwind CSS: grab a row by its handle, it lifts with a soft shadow while neighbours slide out of the way, and the new order comes back through onReorder. Keyboard users can pick up, move and drop rows with Space and the arrow keys, with every move announced to screen readers.

  • Drag handle
  • Layout springs
  • Keyboard reordering
  • Live announcements
  • Touch-ready
  • prefers-reduced-motion

Priorities

  • Ship the launch page

    Marketing · Fri

    #1
  • Rotate auth secrets

    Security · Today

    #2
  • Cut cold start under 200 ms

    Platform · Next week

    #3
  • Fix flaky checkout test

    QA · Tomorrow

    #4
  • Polish onboarding motion

    Design · Backlog

    #5

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

Installation

$ npx shadcn@latest add https://duskui.com/r/sortable-list.json

Usage

todo-order.tsx
"use client"

import * as React from "react"
import { SortableList } from "@/components/dusk/sortable-list/sortable-list"

export function TodoOrder() {
  const [todos, setTodos] = React.useState([
    { id: "1", title: "Write the spec" },
    { id: "2", title: "Review designs" },
    { id: "3", title: "Ship it" },
  ])

  return (
    <SortableList
      items={todos}
      onReorder={setTodos}
      getLabel={(todo) => todo.title}
      renderItem={(todo) => todo.title}
    />
  )
}

Examples

Play queue

Any content fits in renderItem; derived values such as the total duration stay in sync because the order lives in your state.

Up next

14:02 total

  • Neon Tide

    Halcyon Drive

    3:34
  • Glass Avenue

    Mira Vale

    3:07
  • After Hours

    Static Bloom

    4:03
  • Low Orbit

    Kepler Kids

    3:18

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

Plain strings

Strings and numbers are their own keys, so getKey is optional. Objects default to item.id.

  • Install
  • Configure
  • Build
  • Test
  • Deploy

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

API Reference

Also accepts any div attribute for the wrapper. Items must be stable references or have stable keys.

PropTypeDefaultDescription
itemsT[]—The items, in order.
onReorder(items: T[]) => void—Called with the new order while dragging and on every keyboard move.
renderItem(item: T, state: { index; active }) => ReactNode—Row content. The drag handle is rendered for you.
getKey(item: T) => stringitem.id ?? String(item)Stable key per item.
getLabel(item: T) => string—Name used in the handle's label and in announcements. Defaults to the key.
labelstring"Sortable list"Accessible name for the list.
itemClassNamestring—Classes for every row.

Accessibility

  • The list is a real ul; each handle is a button labelled “Reorder <item>” and described by the keyboard instructions.
  • Focus a handle and press Space or Enter to pick the row up, Arrow Up / Arrow Down (or Home / End) to move it, Space or Enter to drop, and Escape to put it back where it started.
  • While nothing is picked up, Arrow Up / Arrow Down hop between handles.
  • Every pick-up, move, drop and cancel is announced through an assertive live region, including the new position out of the total.
  • Focus stays on the moved row's handle; tabbing away while holding a row drops it in place.
  • With prefers-reduced-motion, rows snap into place instead of springing.