"use client";
import { SortableList } from "@pixxl-tools/components";| Prop | Type | Default | Description |
|---|---|---|---|
items (required) | readonly Item[] | — | Items to render. |
onReorder (required) | (from: number, to: number) => void | — | Called once per completed move (pointer drop or keyboard drop). |
renderItem (required) | (item: Item, state: SortableItemState) => ReactNode | — | Row content. |
isItemDisabled | (item: Item, index: number) => boolean | — | Items that cannot be picked up (e.g. locked layers); others can pass them. |
renderActions | (item: Item, state: SortableItemState) => ReactNode | — | Item actions slot (visibility / lock toggles, delete…), after the content. |
autoScroll | boolean | true | Scroll the nearest scroll container near its edges while dragging (default true). |
disabled | boolean | — | Disables interaction. |
dragFrom | "handle" | "item" | handle | handle (default): pointer drags start on the handle. item: anywhere on the row with mouse or pen (touch keeps using the handle so the page still scrolls). |
getItemId | (item: Item, index: number) => string | item.id | Stable id (default item.id, then the index). |
getItemLabel | (item: Item, index: number) => string | item.label | Name used in announcements and the handle label (default item.label). |
handleLabel | (itemLabel: string) => string | from messages: "Reorder {item}" | Accessible name of a handle (default from messages: "Reorder {item}"). |
label | string | — | Accessible name of the list. |
size | "md" | "sm" | — | Size from the shared scale (xs, sm, md, lg). |
itemsrequiredreadonly Item[]
Items to render.
onReorderrequired(from: number, to: number) => void
Called once per completed move (pointer drop or keyboard drop).
renderItemrequired(item: Item, state: SortableItemState) => ReactNode
Row content.
isItemDisabled(item: Item, index: number) => boolean
Items that cannot be picked up (e.g. locked layers); others can pass them.
renderActions(item: Item, state: SortableItemState) => ReactNode
Item actions slot (visibility / lock toggles, delete…), after the content.
autoScrolldefault trueboolean
Scroll the nearest scroll container near its edges while dragging (default true).
disabledboolean
Disables interaction.
dragFromdefault handle"handle" | "item"
handle (default): pointer drags start on the handle. item: anywhere on the row with mouse or pen (touch keeps using the handle so the page still scrolls).
getItemIddefault item.id(item: Item, index: number) => string
Stable id (default item.id, then the index).
getItemLabeldefault item.label(item: Item, index: number) => string
Name used in announcements and the handle label (default item.label).
handleLabeldefault from messages: "Reorder {item}"(itemLabel: string) => string
Accessible name of a handle (default from messages: "Reorder {item}").
labelstring
Accessible name of the list.
size"md" | "sm"
Size from the shared scale (xs, sm, md, lg).
Other props are passed to the root element (HTMLAttributes<HTMLDivElement>), including className, style, id and aria-* attributes.
Title
Photo
Background shape
Logo
Caption
type Layer = { id: string; label: string; locked?: boolean; visible: boolean };
const [layers, setLayers] = useState<Layer[]>([
{ id: "text", label: "Text", visible: true },
{ id: "background", label: "Background", locked: true, visible: true },
]);
function LayerToggles({ layer }: { layer: Layer }) {
return <span>{layer.visible ? "Visible" : "Hidden"}</span>;
}
<SortableList items={layers} onReorder={(from, to) => setLayers(moveItem(layers, from, to))} isItemDisabled={(layer) => Boolean(layer.locked)} renderItem={(layer) => layer.label} renderActions={(layer) => <LayerToggles layer={layer} />} />