Usage
TheuseSortable hook combines draggable and droppable behavior with sorting logic. Import it from @dnd-kit/solid/sortable.
Use getter syntax for reactive props to maintain Solid’s fine-grained reactivity. Without getters, the hook reads prop values once during setup and never re-runs its effects when they change.
Without the move helper
The example above uses themove helper from @dnd-kit/helpers, a convenience function that takes your items and a drag event and returns a new array with the item moved to its new position. It supports flat arrays and grouped records, handles canceled drags, and works with optimistic sorting out of the box.
If you need more control over state updates, you can manage state manually using the isSortable type guard and the sortable properties (initialIndex, index).
With optimistic sorting enabled (the default), you only need to handle the onDragEnd event:
Learn more about optimistic sorting, type guards, and manual state management in the Sortable concepts page.
Input
A unique identifier. Use
get id() { return props.id } for reactive values.The current index in the sorted list. Use
get index() { return props.index } for reactive values.The group this sortable belongs to. Used for sorting across multiple lists.
A handle element. Use the
handleRef callback to set it.The types of draggable elements this sortable accepts.
The type of this sortable element.
An array of plugin descriptors for per-entity plugin configuration. Use
Plugin.configure() to create descriptors. For example, Feedback.configure({ feedback: 'clone' }).Animation transition configuration.
Modifiers to apply to this sortable instance.
Sensors to use for this sortable instance.
A custom collision detection algorithm.
The collision priority of this sortable element. Higher values take precedence when multiple droppable elements overlap.
Whether the sortable is disabled.
Custom data to attach to this sortable instance.
Output
A callback ref to attach to the sortable element.
A callback ref for a drag handle.
A callback ref for the drag source element.
A callback ref for the drop target element.
Whether this element is currently being dragged. Call as
isDragging() in JSX.Whether this element is in the process of being dropped. Call as
isDropping() in JSX.Whether this element is the source of the current drag operation. Call as
isDragSource() in JSX.Whether this element is currently a drop target. Call as
isDropTarget() in JSX.The underlying
Sortable instance.