# Reorder List

> A list people can reorder by dragging or from the keyboard, with springy movement.

Source: https://www.honestui.com/docs/animated/reorder-list

```tsx
"use client";

import { useState } from "react";
import { Bug, FileText, GitPullRequest, Rocket, Users } from "honestui/icons";
import { ReorderList } from "@/registry/default/animated/reorder-list";

type Task = {
  id: string;
  title: string;
  meta: string;
  icon: typeof Bug;
};

const TASKS: Task[] = [
  { id: "checkout", title: "Fix checkout timeout", meta: "Bug · 3 reports", icon: Bug },
  { id: "review", title: "Review billing changes", meta: "Pull request · 12 files", icon: GitPullRequest },
  { id: "launch", title: "Ship onboarding v2", meta: "Launch · Friday", icon: Rocket },
  { id: "interviews", title: "Synthesize interviews", meta: "Research · 8 notes", icon: Users },
  { id: "docs", title: "Update API docs", meta: "Docs · 2 pages", icon: FileText },
];

export function ReorderListDemo() {
  const [tasks, setTasks] = useState(TASKS);

  return (
    <div className="flex w-full max-w-sm flex-col gap-3">
      <div className="flex items-baseline justify-between px-1">
        <p className="text-sm font-semibold text-foreground">This week&apos;s priorities</p>
        <button
          type="button"
          onClick={() => setTasks(TASKS)}
          className="text-xs text-muted-foreground underline-offset-4 hover:text-foreground hover:underline"
        >
          Reset
        </button>
      </div>
      <ReorderList
        label="This week's priorities"
        items={tasks}
        onReorder={setTasks}
        getKey={(task) => task.id}
        getLabel={(task) => task.title}
        renderItem={(task, { index }) => {
          const Icon = task.icon;
          return (
            <div className="flex items-center gap-3">
              <span className="grid size-8 shrink-0 place-items-center rounded-md border border-border text-muted-foreground">
                <Icon className="size-4" aria-hidden="true" />
              </span>
              <div className="min-w-0 flex-1">
                <p className="truncate text-sm font-medium text-foreground">{task.title}</p>
                <p className="truncate text-xs text-muted-foreground">{task.meta}</p>
              </div>
              <span className="text-xs text-muted-foreground tabular-nums" aria-hidden="true">
                {index + 1}
              </span>
            </div>
          );
        }}
      />
    </div>
  );
}

```

## Overview [#overview]

Reorder List lets people put a short list in their own order: priorities, steps, playlist tracks, or navigation items. Rows lift as they are picked up, and the others slide aside with a spring. Every row has a handle, which works with a pointer and with the keyboard, and each move is announced to screen readers.

The list is controlled. Pass the items in their current order and update them in `onReorder`.

## Installation [#installation]

<CliBlock commands="[&#x22;reorder-list&#x22;]" />

## Usage [#usage]

```tsx
import { ReorderList } from "@/components/animated/reorder-list"

const [tasks, setTasks] = useState(initialTasks)

<ReorderList
  label="Priorities"
  items={tasks}
  onReorder={setTasks}
  getKey={(task) => task.id}
  getLabel={(task) => task.title}
  renderItem={(task) => <span>{task.title}</span>}
/>
```

`renderItem` draws the content of each row after the handle. It receives the item and `{ active, index }`, so a row can change while it is being moved or show its position.

### Drag the whole row [#drag-the-whole-row]

By default only the handle starts a pointer drag, which keeps links and buttons inside a row usable. Set `handle={false}` to let the whole row drag. Keyboard reordering always uses the handle.

## Accessibility [#accessibility]

Each handle is a button named "Reorder" followed by the item's label, and it describes the keys to use.

| Key                  | Action                                                |
| -------------------- | ----------------------------------------------------- |
| Space, Enter         | Pick up the focused item, or drop it.                 |
| Arrow Up, Arrow Down | Move the picked-up item one place.                    |
| Home, End            | Move the picked-up item to the start or end.          |
| Escape               | Cancel and return the item to where it was picked up. |

Focus stays on the handle while its row moves. Moving focus away drops the item where it is. Picking up, moving, dropping, and cancelling are announced in a polite live region, such as "Picked up Review billing changes. Position 2 of 5." Pass `announcements` and `instructions` to translate or reword them.

With reduced motion enabled, rows move straight to their new place and the picked-up row does not grow; its shadow still marks it.

## API Reference [#api-reference]


  ### `items`

type: `T[]`

Items in their current order.

  ### `onReorder`



void">
    Called with the items in their new order.

  ### `getKey`



string">
    A stable key for each item.

  ### `getLabel`



string">
    Plain-text name of each item, used for the handle and announcements.

  ### `renderItem`



ReactNode">
    Content of each row, drawn after the handle.

  ### `handle`

type: `boolean` · default: `true`

Start pointer drags only from the handle. When false, the whole row drags.

  ### `disabled`

type: `boolean` · default: `false`

Turns off dragging and keyboard moves.

  ### `label`

type: `string`

Accessible name of the list.

  ### `instructions`

type: `string`

Key instructions read with each handle.

  ### `announcements`



">
    Replace the 

    `pickedUp`

    , 

    `moved`

    , 

    `dropped`

    , or 

    `cancelled`

     messages. Each receives the label, the one-based position, and the total.

  ### `getHandleLabel`



string" default="&#x22;Reorder {label}&#x22;">
    Accessible name of each handle.

  ### `className`

type: `string`

Class for the list.

  ### `itemClassName`

type: `string`

Class for each row.
