# Sortable list

Reorder one consumer-owned list with explicit native move actions and accepted-state feedback.

Access: pro. Category: Essentials. Kind: composite.

## When to use

- Use it when a page needs reorder one consumer-owned list with explicit native move actions and accepted-state feedback.
- Choose it when the host application can supply the required state and keep business logic outside the presentation component.

## Alternatives

- Choose tidal-button instead when press, loading, success and disabled states is the actual interface need, rather than sortable list.

## Setup for agents

Use React 19 and TypeScript. Initialize shadcn for your framework, then merge this exact entry into components.json:

```json
{
  "registries": {
    "@tidal-pro": {
      "url": "https://tidalui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${TIDALUI_TOKEN}"
      }
    }
  }
}
```

The namespace must be named **@tidal-pro** because transitive Pro dependencies use that namespace. Obtain an agent key from your active Pro account at https://tidalui.com/account. Keep TIDALUI_TOKEN in your local environment, never in components.json, client code, Git or logs.

```sh
export TIDALUI_TOKEN='your-private-agent-key'
npx shadcn@latest add @tidal-pro/waitlist-form
npx shadcn@latest add https://tidalui.com/r/tidal-button.json
```

Free command: `npx shadcn@latest add https://tidalui.com/r/<name>.json`.
Pro command: `npx shadcn@latest add @tidal-pro/<name>`.

Import the base stylesheet and every stylesheet listed on the installed item's metadata. For example:

```tsx
import "./components/ui/tidal.css";
import "./components/ui/hero-section.css";
// Place installed components inside this wrapper:
<div className="tidal-scope" data-theme="dark">...</div>
```

Omit data-theme for the default light theme. Put the attribute on the same tidal-scope element for dark mode. Every component installs the shared free tidal-base dependency. After upgrading, run `npx shadcn@latest add https://tidalui.com/r/tidal-base.json --overwrite` to receive current tokens. Review local modifications before overwriting.

Vite: Use React + TypeScript. Map @/* to ./src/* in paths and Vite resolve.alias. Import tidal.css and each component stylesheet in your application entry.

Next.js 15 App Router: Next.js App Router: import tidal.css and component CSS in app/layout.tsx. Interactive examples belong in a client component with "use client". Map @/* to ./* or ./src/* to match your project.

TypeScript 6: use paths without baseUrl:

```json
{
  "compilerOptions": {
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
  }
}
```

Pro registry requests are server/CLI-only. Use the same-origin account interface in a browser; cross-origin Authorization preflights are intentionally unsupported.


## Install Sortable list

```sh
npx shadcn@latest add @tidal-pro/sortable-list
```

Stylesheets: `components/ui/tidal.css`, `components/ui/sortable-list.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/sortable-list.css";
import{TidalSortableList}from"./components/ui/sortable-list";
export default()=><div className="tidal-scope"><TidalSortableList items={[{id:"example",label:"Demo"}]} label={"Demo"} onOrderChange={() => {}}/></div>;
```

## Structured props

- `TidalSortableList.items: ReadonlyArray<TidalSortableListItem>`: Required items value accepted by this exported component.
- `TidalSortableList.label: string`: Required label value accepted by this exported component.
- `TidalSortableList.onOrderChange: (nextItems: TidalSortableListItem[], move: TidalSortMove, event: MouseEvent<HTMLButtonElement>) => void`: Callback invoked when the order change interaction is proposed.
- `TidalSortableList.announceMoves?: boolean | undefined` (default true): Optional announce moves value accepted by this exported component.
- `TidalSortableList.disabled?: boolean | undefined` (default false): Optional disabled value accepted by this exported component.
- `TidalSortableList.emptyMessage?: ReactNode` (default "No items to order."): Optional empty message value accepted by this exported component.
- `TidalSortableList.moveAnnouncement?: ((item: TidalSortableListItem, fromIndex: number, toIndex: number, total: number) => string) | undefined` (default (item, _fromIndex, toIndex, total) =>
      `${item.label} moved to position ${toIndex + 1} of ${total}.`): Optional move announcement value accepted by this exported component.
- `TidalSortableList.moveDownLabel?: ((item: TidalSortableListItem, index: number) => string) | undefined` (default (item) => `Move ${item.label} down`): Optional move down label value accepted by this exported component.
- `TidalSortableList.moveUpLabel?: ((item: TidalSortableListItem, index: number) => string) | undefined` (default (item) => `Move ${item.label} up`): Optional move up label value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/sortable-list.tsx) | [Manifest](https://tidalui.com/examples/sortable-list.json). Install the listed additional dependencies. Consumer fixture: TypeScript pass; Vite pass. This fixture check is distinct from the actual shadcn install receipt.

```tsx
"use client";

import "./components/ui/tidal.css";

import { useState } from "react";

import { CheckSquare2, FileText, Smartphone, Stamp } from "lucide-react";

import { TidalSortableList, type TidalSortableListItem } from "./components/ui/sortable-list";

import "./components/ui/sortable-list.css";



const tidalExampleStyles = ".tidal-scope .sortable-list-demo,\n.tidal-scope .sortable-list-demo * {\n  box-sizing: border-box;\n}\n\n.tidal-scope .sortable-list-demo {\n  container: sortable-list-demo / inline-size;\n  display: grid;\n  gap: 14px;\n  width: min(100%, 680px);\n  min-width: 0;\n  color: var(--t-ink);\n}\n\n.tidal-scope .sortable-list-demo-footer {\n  display: flex;\n  min-width: 0;\n  align-items: center;\n  justify-content: space-between;\n  gap: 12px;\n  padding-top: 2px;\n}\n\n.tidal-scope .sortable-list-demo-footer p,\n.tidal-scope .sortable-list-demo-note {\n  min-width: 0;\n  margin: 0;\n  color: var(--t-muted);\n  font-size: 11px;\n  line-height: 1.5;\n  overflow-wrap: anywhere;\n}\n\n.tidal-scope .sortable-list-demo-footer button {\n  min-width: 110px;\n  min-height: 44px;\n  flex: 0 0 auto;\n  padding: 9px 13px;\n  border: 1px solid var(--t-border);\n  border-radius: var(--t-radius-control);\n  background: var(--t-surface);\n  color: var(--t-ink);\n  font: inherit;\n  font-size: 12px;\n  font-weight: 650;\n  cursor: pointer;\n  transition:\n    background-color 160ms,\n    color 160ms,\n    transform 140ms var(--t-ease-out);\n}\n\n.tidal-scope .sortable-list-demo-footer button:hover {\n  background: var(--t-ink);\n  color: var(--t-surface);\n}\n\n.tidal-scope .sortable-list-demo-footer button:active {\n  transform: scale(0.97);\n}\n\n.tidal-scope .sortable-list-demo-footer button:focus-visible {\n  outline: 2px solid var(--t-accent);\n  outline-offset: 3px;\n}\n\n@container sortable-list-demo (max-width: 360px) {\n  .tidal-scope .sortable-list-demo-footer {\n    align-items: stretch;\n    flex-direction: column;\n  }\n\n  .tidal-scope .sortable-list-demo-footer button {\n    width: 100%;\n  }\n}\n\n@media (prefers-reduced-motion: reduce) {\n  .tidal-scope .sortable-list-demo-footer button {\n    transition: none;\n  }\n\n  .tidal-scope .sortable-list-demo-footer button:active {\n    transform: none;\n  }\n}";

const INITIAL_ITEMS: readonly TidalSortableListItem[] = [
  {
    id: "mobile",
    label: "Review mobile states",
    description: "Check the 320px and 390px layouts.",
    meta: "Today",
    icon: <Smartphone aria-hidden="true" />,
  },
  {
    id: "copy",
    label: "Approve release copy",
    description: "Confirm labels and local sample disclosures.",
    meta: "Next",
    icon: <CheckSquare2 aria-hidden="true" />,
  },
  {
    id: "notes",
    label: "Prepare release notes",
    description: "Summarize the accepted interface changes.",
    meta: "Later",
    icon: <FileText aria-hidden="true" />,
  },
  {
    id: "snapshot",
    label: "Published snapshot",
    description: "Locked after the sample release was prepared.",
    meta: "Locked",
    icon: <Stamp aria-hidden="true" />,
    disabled: true,
  },
];

export function SortableListDemo() {
  const [items, setItems] = useState<TidalSortableListItem[]>([
    ...INITIAL_ITEMS,
  ]);
  const [status, setStatus] = useState(
    "Use the arrow actions to set priority.",
  );

  return (
    <section className="sortable-list-demo" aria-label="Release priority list">
      <TidalSortableList
        label="Release priorities"
        items={items}
        onOrderChange={(nextItems, move) => {
          setItems(nextItems);
          setStatus(
            `${nextItems[move.toIndex]?.label} is now priority ${move.toIndex + 1}.`,
          );
        }}
      />
      <div className="sortable-list-demo-footer">
        <p>{status}</p>
        <button
          type="button"
          onClick={() => {
            setItems([...INITIAL_ITEMS]);
            setStatus("Priority order reset.");
          }}
        >
          Reset order
        </button>
      </div>
      <p className="sortable-list-demo-note">
        Sample priorities. Changes stay in this preview.
      </p>
    </section>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <SortableListDemo />
    </div>
  );
}

```

## Gotchas

- Install the declared registry dependencies and render inside a tidal-scope with the foundation stylesheet loaded.

## Theme and accessibility

{"tokens":["--t-accent","--t-border","--t-border-strong","--t-canvas","--t-danger","--t-display","--t-ease-out","--t-ease-spring","--t-faint","--t-font","--t-ink","--t-line","--t-muted","--t-primary","--t-primary-contrast","--t-radius-card","--t-radius-control","--t-radius-overlay","--t-radius-panel","--t-ring","--t-shadow-lg","--t-shadow-soft","--t-soft","--t-subtle","--t-surface","--t-wash"],"darkMode":true}

{"keyboard":["Tab and Shift+Tab follow the component's native focus order.","Arrow-key behavior follows the exported composite-control implementation."],"aria":"The component wires labels and relationships from consumer-provided visible text or ARIA props; preserve those labels in production.","notes":"Verify focus visibility, text alternatives, contrast, and reduced motion in the final composition."}

Controlled ordered items require unique IDs and string labels and support description, meta, decorative icon, disabled state, native list-item props/ref and separate native Move up/down button props/refs. onOrderChange receives the proposed item array, item ID, from/to indexes, direction and native click event; consumers accept or decline the proposal. Locked disabled items cannot move or be crossed. Root label/native ordered-list props/ref and disabled state are available. All move actions are type=button, 44px, caller-first and keyboard reachable through ordinary Tab navigation. Accepted moves announce the new position by default and recover focus within the same row only when the pressed boundary action becomes disabled. Optional label/announcement formatters, emptyMessage and announceMoves=false are supported. Consumers own ordering, validation, persistence and side effects; no drag behavior or form value is implied.
