Sortable List
Drag-and-drop sortable list
UI PrimitiveForm Inputs
Overview
A compound component powered by @dnd-kit/core and @dnd-kit/sortable. Items are rendered via a render prop. Keyboard and pointer sensors are supported. A drag handle sub-component is provided for explicit drag zones.
Usage
import { SortableList } from "@leanicon/web-builder-library";
const [items, setItems] = React.useState([
{ id: "1", label: "First" },
{ id: "2", label: "Second" },
{ id: "3", label: "Third" },
]);
<SortableList items={items} onReorder={setItems}>
{(item) => (
<SortableList.Item id={item.id}>
<SortableList.DragHandle />
<span>{item.label as string}</span>
</SortableList.Item>
)}
</SortableList>;Variants
With drag handle
- Design mockups
- Write tests
- Code review
- Deploy to staging
Without drag handle (full row drag)
- High priority
- Medium priority
- Low priority
Disabled
- Locked item A
- Locked item B
- Locked item C
Notes
SortableList.DragHandlehides itself automatically whendisabledistrue.- A
DragOverlayrenders a shadow copy of the active item during drag. - When
onReorderis omitted, the list manages its own order internally. - Dark mode is handled via semantic tokens.
Props
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
items | SortableItem[] | — | Yes | |
onReorder | ((items: SortableItem[]) => void) | — | No | |
disabled | boolean | — | No | |
className | string | — | No | |
id | string | — | Yes |