Quick Example

Drag & Drop Usage

Start with SortableList for list reordering, or useDragDrop for kanban-style moves between zones.

Code

                <script lang="ts">
 import { SortableList, useDragDrop } from 'svelora';

 // Reorder within one list
 let tasks = $state([
   { id: 'a', title: 'Design tokens' },
   { id: 'b', title: 'Ship release' }
 ]);

 // Move between drop zones
 let zone = $state<'a' | 'b' | null>(null);
 const dragDrop = useDragDrop();
</script>

<!-- Sortable list -->
<SortableList bind:items={tasks} getKey={(task) => task.id}>
 {#snippet children({ item })}
   <span>{item.title}</span>
 {/snippet}
</SortableList>

<!-- Cross-container drag -->
<dragDrop.Provider>
 <div use:dragDrop.droppable={{ id: 'a', onDrop: () => (zone = 'a') }}>Zone A</div>
 <div use:dragDrop.droppable={{ id: 'b', onDrop: () => (zone = 'b') }}>Zone B</div>
 {#if zone === 'a' || zone == null}
  <div use:dragDrop.draggable={{ id: 'card', container: zone ?? 'a', data: 'Drag me' }}>
   Drag me
  </div>
 {/if}
</dragDrop.Provider>
            

Drag & Drop

Interactive guide and playground for sortable lists and cross-container drag, powered by @dnd-kit/svelte. Built with useSortable, useDragDrop, and SortableList. Advanced demos below also mirror the dnd-kit-svelte examples (basic, sortable columns, nested containers), adapted for official @dnd-kit/svelte.

When to use what

SortableList

Fastest path for vertical, horizontal, or grid lists with bind:items.

SortableList docs

useSortable

Full control over row markup, handles, and axis modifiers.

useSortable docs

useDragDrop

Move cards between columns, folders, or kanban lanes.

useDragDrop docs

Basic

Cross-container drag with three drop zones — ported from the dnd-kit-svelte basic example via useDragDrop.

Drag me
Drop here
Drop here
Drop here

Task columns

Two-column task board with live column switching on drag-over and reorder on drop — from the sortable example using @dnd-kit/svelte directly.

In Progress

Learn Svelte
Build a Kanban board
Review code
Setup project

Done

Nested containers

Sortable task groups with nested items that can move between containers — from the nested example.

Development Tasks

Technical implementation tasks

Setup Project

Initialize repository and configure tools

Create Components

Build reusable UI components

Design Tasks

UI/UX design related tasks

Color Palette

Define brand colors and variants

Typography

Select and implement fonts

Drag containers to reorder groups, or move tasks between them.

Sortable list

Design review #1
Implement API #2
Write tests #3
Ship release #4

Horizontal

Draft
Review
Publish

Grid

CSS Grid layout — dnd-kit detects 2D flow automatically when axis is grid.

1
2
3
4
5
6
7
8
9

Drag handle

Only the grip starts a drag
Buttons below stay clickable

Whole row drag

Drag anywhere on this row
No grip handle

Disabled

Design review
Implement API
Write tests
Ship release

Interactive elements

Drag from the grip only — inputs and buttons stay interactive (built into @dnd-kit).

Multiple lists

Backlog

List A — item 1
List A — item 2

This sprint

List B — item 1
List B — item 2

Kanban (2 columns)

todo

Design tokens
Hook API

done

Kickoff

Kanban (3 columns)

todo

Wireframes
User flows

In progress

Component library

done

Project setup

Conditional drop

Archive rejects items whose label contains draft (case-insensitive).

Inbox

Invoice.pdf
Notes.txt

Archive

accept — blocks "draft" files

Old draft

Rich content

Fix login redirect high
Update dependencies medium
Polish empty states low

Manual markup

Manual markup
Full control
Custom styling
useSortable

Hook API and manual markup.

useDragDrop

Cross-container kanban patterns.

SortableList

Styled component with bind:items.