Drag and Drop

Declarative, data-driven drag and drop components for sortable lists and Kanban-style layouts. Built on svelte-dnd-action with Svelte 5 runes.

Each item needs a stable, unique string or number id. IDs must be unique across all lists in a group. Give independent lists unique list IDs too: ungrouped lists with matching IDs share the same engine zone type. Pointer and keyboard sorting update bind:items on finalize; onchange runs only when the finalized ID order differs from its previous snapshot. Pointer dragging finalizes on drop; keyboard arrow moves finalize immediately, so keyboard persistence may run more than once during a grab.

Version 0.0.34 limitation: SortableGroup shares a zone type, but its rules and typeField are not consumed by the current SortableList implementation. Do not rely on them to reject cross-list moves.


Simple List

SortableList renders a one-dimensional sortable list. Item order can be changed by dragging; bind:items keeps state in sync automatically.

Design system tokens
Implement SortableList
Write documentation
Add unit tests
Publish to npm

Kanban Board

SortableGroup connects multiple SortableList instances, enabling items to be moved between columns. The items binding on each list stores its final order. This board accepts both tasks and bugs in every column; group rules are not enforced in 0.0.34.

Backlog

Design new logo
Fix login bug
Refactor API

To Do

Write tests

Done

Setup project

Drag Handle

dragHandleSelector restricts drag initiation to a specific element inside each item. Set the selector on the list and add a matching attribute (e.g. data-drag-handle) to your handle element. The rest of the item — inputs, buttons, text — remains fully interactive and will never accidentally start a drag.

Design system tokens
Implement SortableList
Write documentation
Add unit tests
Publish to npm

Horizontal List

orientation="horizontal" switches the layout to left-to-right. The drop indicator and sort logic adapt automatically.

Design
Development
Testing
Review
Deploy

Grid Layout

orientation="grid" produces a wrapping (flex-wrap) horizontal layout — ideal for fixed-width items such as files or cards.

png
avatar.png 24 KB
svg
logo.svg 4 KB
pdf
report-q1.pdf 1.2 MB
html
index.html 8 KB
css
styles.css 16 KB
ts
main.ts 12 KB
json
data.json 3 KB
jpg
background.jpg 640 KB
md
notes.md 2 KB
pptx
presentation.pptx 5.4 MB
xlsx
spreadsheet.xlsx 220 KB
yaml
config.yaml 1 KB

Custom Drop Indicator

The dropIndicator snippet gives full control over the indicator's appearance. It receives the engine’s shadow item (typed as item or undefined), so the indicator can reflect the item's own color or type. The snippet replaces the shadow item’s content while dragging; the wrapper still participates in the sortable layout.

Design system
API integration
User research
Performance audit
Documentation

Grabbed Item Style

grabbedClass applies Tailwind classes to the drag element’s first child — tilt, scale, shadow, opacity, or any combination. This uses the sortable engine’s element transform, not the native-preview helpers.

Design tokens
SortableList
Documentation
Unit tests
Publish

Empty State

The empty prop renders an EmptyState when the list has no items. Particularly useful in Kanban layouts where a column can become empty during a drag session. icon and title are required; description is optional.

To Do

Write tests
Fix login bug
Update dependencies

Done

Nothing done yet

Drop completed tasks here.

Archived

Archive is empty

Move tasks here to archive them.


Finalized changes and keyboard sorting

Use onchange to persist finalized changes or inspect movement metadata. Press Space or Enter to pick up a focused item, use arrows to move it, then Space, Enter or Escape to end the grab. In the installed engine, Escape drops at the current position; it does not restore the original order. Arrow moves emit finalize events immediately.

Design
Implement
Review

Reorder an item with the pointer, or focus it and press Space, arrows, then Space.


Low-level native drag actions

The separate dnd actions use Pragmatic DnD, not the SortableList engine. They do not reorder arrays or interoperate with sortable zones automatically. Supply data, canDrop and event callbacks to implement your own native-pointer behavior.

Drag the card into the target.


Standalone indicators

DropSlot is a visual insertion slot driven by atIndex and insertIndex. DropIndicator registers a native drop target with { type: "list-indicator", listId }; it delegates events to your callbacks. Neither is used internally by SortableList in 0.0.34, and neither moves data by itself.

Before
After