nook
Browse the docs

Components

Sortable list

Built on Base UI

A reorderable list with touch-friendly handles, keyboard pickup, and spoken position updates.

See the prompt

Your focus queue

Drag a handle, or press Space and use the arrow keys.

Press Space to pick up, arrows to move, Space to drop, or Escape to cancel. You can also drag the handle.

  • Read the project brief

    Start with the problem we’re solving

    5 min
  • Review customer conversations

    Three interviews from last week

    20 min
  • Sketch the first direction

    A rough idea is enough

    30 min
  • Share with the team

    Leave room for a different perspective

    10 min

Installation

npx nook-ui@latest add sortable-list

Prompt

Paste this into your AI coding assistant. It adds this exact component, the same way the CLI does, and tells the assistant how to use it.

Short. For assistants that can run commands in your project.

Plain text
Add the Nook "Sortable list" component to this project, exactly as Nook ships it.

A reorderable list with touch-friendly handles, keyboard pickup, and spoken position updates.

Steps
1. Check for `nook.json` in the project root. If it is missing, run `npx nook-ui@latest init` first (React or Next.js with Tailwind CSS v4). It adds the Nook tokens, the theme and `cn()`.
2. Run `npx nook-ui@latest add sortable-list`. It writes `components/ui/sortable-list.tsx` together with everything the component needs. Do not write the component from memory.
3. If you cannot run commands, fetch http://localhost:3000/r/sortable-list.json, write every entry of `files` to the path it names, install the packages in `dependencies`, and repeat for each name in `registryDependencies`.
4. Use it where I ask. Start from this example:

```tsx
"use client";

import * as React from "react";
import { SortableList } from "@/components/ui/sortable-list";
import { Badge } from "@/components/ui/badge";

const initial = [
  { id: "brief", title: "Read the project brief", note: "Start with the problem we’re solving", time: "5 min" },
  { id: "research", title: "Review customer conversations", note: "Three interviews from last week", time: "20 min" },
  { id: "sketch", title: "Sketch the first direction", note: "A rough idea is enough", time: "30 min" },
  { id: "share", title: "Share with the team", note: "Leave room for a different perspective", time: "10 min" },
];
export default function SortableListDefault() {
  const [items, setItems] = React.useState(initial);
  return <div className="grid w-full gap-3"><div><h3 className="font-semibold">Your focus queue</h3><p className="mt-1 text-xs text-muted-foreground">Drag a handle, or press Space and use the arrow keys.</p></div><SortableList aria-label="Focus queue" items={items} getKey={(item) => item.id} getLabel={(item) => item.title} onReorder={setItems} renderItem={(item) => <div className="flex min-w-0 items-center justify-between gap-3"><div className="min-w-0"><p className="font-medium">{item.title}</p><p className="mt-0.5 text-xs text-muted-foreground">{item.note}</p></div><Badge variant="outline">{item.time}</Badge></div>} /></div>;
}
```

API
- `SortableList<T>`: Own the items in your app and apply every onReorder result. Stable keys preserve focus. Interactive item content stays separate from the drag handle.
  - `items, getKey` (`T[], (item: T) => string`): Ordered data and a stable, unique key for each item.
  - `renderItem` (`(item: T, index: number) => ReactNode`): The content beside each handle.
  - `getLabel` (`(item: T) => string`): Plain words used in handle names and announcements. Supply for meaningful labels.
  - `onReorder` (`(items: T[]) => void`): Called for moves and cancellation. Replace the controlled items with this result.
  - `disabled, emptyText` (`boolean, string`): Disable handles or replace the empty message.
- `SortControl`: A field select and descending toggle. Apply value.direction to the sorted table header’s aria-sort attribute.
  - `fields` (`{ value: string; label: string }[]`): Fields the list or table can sort by.
  - `value, defaultValue, onValueChange` (`SortValue, SortValue, (sort: SortValue) => void`): A field and direction (ascending or descending). Sorting the data is the caller’s responsibility.

Rules
- Colors, radii, shadows and motion come from Nook tokens and classes such as `bg-primary`, `text-muted-foreground`, `border-border`, `rounded-lg` and `h-control`. Never hard-code them.
- Do not restyle or simplify the file. Change how it looks through `className`, its props and the theme.
- It must keep working with the keyboard, in light and dark mode, and in the sharp, soft and bold styles.
- Accessibility: Space picks up a handle, arrows move it, Space drops it and Escape restores its order. Home and End move to either end. Polite announcements describe position. Pointer capture supports mouse, pen and touch without blocking scrolling outside the handle.

Done when the component renders like the example in light and dark mode and the project type-checks.

Usage

"use client";

import * as React from "react";
import { SortableList } from "@/components/ui/sortable-list";
import { Badge } from "@/components/ui/badge";

const initial = [
  { id: "brief", title: "Read the project brief", note: "Start with the problem we’re solving", time: "5 min" },
  { id: "research", title: "Review customer conversations", note: "Three interviews from last week", time: "20 min" },
  { id: "sketch", title: "Sketch the first direction", note: "A rough idea is enough", time: "30 min" },
  { id: "share", title: "Share with the team", note: "Leave room for a different perspective", time: "10 min" },
];
export default function SortableListDefault() {
  const [items, setItems] = React.useState(initial);
  return <div className="grid w-full gap-3"><div><h3 className="font-semibold">Your focus queue</h3><p className="mt-1 text-xs text-muted-foreground">Drag a handle, or press Space and use the arrow keys.</p></div><SortableList aria-label="Focus queue" items={items} getKey={(item) => item.id} getLabel={(item) => item.title} onReorder={setItems} renderItem={(item) => <div className="flex min-w-0 items-center justify-between gap-3"><div className="min-w-0"><p className="font-medium">{item.title}</p><p className="mt-0.5 text-xs text-muted-foreground">{item.note}</p></div><Badge variant="outline">{item.time}</Badge></div>} /></div>;
}

Examples

Sort project documents

Project documents
DocumentUpdated
Customer notes2026-11-16
Release checklist2026-11-14
Design principles2026-11-12

Playlist

Road trip playlist

Press Space to pick up, arrows to move, Space to drop, or Escape to cancel. You can also drag the handle.

  • 1Morning light · Kei Tanaka3:42
  • 2Paper boats · The Low Tide4:10
  • 3Nine to five · Ada Okoye2:58
  • 4Slow burn · Marlo5:21

Empty and locked

Favorites

Press Space to pick up, arrows to move, Space to drop, or Escape to cancel. You can also drag the handle.

  • Star a report to pin it here

Report outline (locked while published)

Press Space to pick up, arrows to move, Space to drop, or Escape to cancel. You can also drag the handle.

  • Cover page
  • Table of contents
  • Summary

Props

SortableList<T>

Own the items in your app and apply every onReorder result. Stable keys preserve focus. Interactive item content stays separate from the drag handle.

PropTypeDefaultDescription
items, getKeyT[], (item: T) => string–Ordered data and a stable, unique key for each item.
renderItem(item: T, index: number) => ReactNode–The content beside each handle.
getLabel(item: T) => string–Plain words used in handle names and announcements. Supply for meaningful labels.
onReorder(items: T[]) => void–Called for moves and cancellation. Replace the controlled items with this result.
disabled, emptyTextboolean, string–Disable handles or replace the empty message.

SortControl

A field select and descending toggle. Apply value.direction to the sorted table header’s aria-sort attribute.

PropTypeDefaultDescription
fields{ value: string; label: string }[]–Fields the list or table can sort by.
value, defaultValue, onValueChangeSortValue, SortValue, (sort: SortValue) => void–A field and direction (ascending or descending). Sorting the data is the caller’s responsibility.

Accessibility

Space picks up a handle, arrows move it, Space drops it and Escape restores its order. Home and End move to either end. Polite announcements describe position. Pointer capture supports mouse, pen and touch without blocking scrolling outside the handle.

Checked against WCAG 2.1 AA with automated axe tests and keyboard tests on every release.