Skip to content
Eskais UI

Data

Sortable

Reorder a list or grid by drag, keyboard and agents, built with definePrimitive over UI SDK's createReorder: a controlled string[] order, a draft while an item moves, an optional drag handle, checked items that move together, announcements with overridable labels, a FLIP slide on the motion tokens, and agent actions move(id, index) and reorder(order).

Example

Sale headline
Product shot
Price badge
Gradient fill

Focus a layer, press Space, move it with the arrows.

Write the brief
Draft the copy
Review with legal
Ship the campaign

Drag by the handle; Open stays a button.

Installation

npx shadcn@latest add @eskais/sortable
npm packageslucide-react

Usage

Import
import { sortable } from "@/components/ui/sortable-primitive"import { sortableLabels, transferLabels } from "@/components/ui/sortable-labels"import { Sortable, SortableHandle, SortableItem } from "@/components/ui/sortable"import { useFlip } from "@/components/ui/use-flip"

Reorder a short list or grid by drag, keyboard and agents. For rows with links or buttons, use List sortable or a SortableHandle.

API reference

Sortable

PropTypeDefault
childrenThe items, or a function of the order to render them in (the draft's while an item moves).ReactNode | ((state: SortableState) => ReactNode)–
labelsPartial<SortableLabels>–
variant"card" | "row" | "plain""card"

Also takes ComponentProps except children.

SortableItem

Takes ComponentProps.

SortableHandle

PropTypeDefault
labelThe item's name; the handle is called `labels.handle(label)`.string–
labelsPartial<SortableLabels>–
valuestring–

Also takes ComponentProps except value.

Other exports

sortablesortableLabelstransferLabelsuseFliptype SortableAutoScrolltype SortableOptionstype SortableReasontype SortableSelectReasontype SortableLabelstype TransferLabelstype SortableHandlePropstype SortableItemPropstype SortablePropstype SortableStatetype SortableVariant

Accessibility

  • Without a handle, a listbox of options with one tab stop: arrows move focus, Space or Enter lifts, the arrows, Home and End move, Space or Enter drops, Escape puts it back.
  • With a handle, a list whose handles are one tab stop and the drag targets, so each item's own controls stay clickable.
  • Every item or handle is described by the keyboard instructions, and each pickup, move and drop is announced; labels overrides the words.
  • The neighbours slide into place with the panel motion token, and stay still under reduced motion.

Agent actions

Agents get move(id, index) and reorder(ids), with items named by itemLabel; wrong ids or indexes come back with what is allowed.

Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.