Architecture
The Svelte integration is built on top of the core@dnd-kit/dom package and provides:
- Primitives: Reactive functions that return state and action functions
- Components: Svelte components for context and overlay management
- Type Safety: Full TypeScript support with proper type inference
- Runes Integration: Deep integration with Svelte 5’s
$effectand$state
Core Concepts
DragDropProvider
The root component that provides drag and drop context to your application:Primitives
Svelte primitives provide reactive drag and drop functionality:- createDraggable: Make elements draggable
- createDroppable: Make elements droppable
- createSortable: Combine draggable and droppable for sortable items
- createDragDropMonitor: Listen to drag and drop events
- createDragOperation: Access the current drag operation state
- getDragDropManager: Access the drag drop manager instance
Element Attachment
Svelte primitives returnattach functions for use with actions:
Installation
Requires Svelte 5 or later for runes support.
Package Exports
Core
DragDropProvider- Context provider componentDragOverlay- Overlay component for drag previewcreateDraggable- Draggable primitivecreateDroppable- Droppable primitivegetDragDropManager- Manager access functioncreateDragDropMonitor- Event monitoring primitivecreateDragOperation- Drag operation state primitivecreateInstance- Instance creation primitive
Sortable
createSortable- Sortable item primitiveisSortable- Type guard for sortable instancesisSortableOperation- Type guard for sortable operations
Utilities
createDeepSignal- Deep reactivity bridge for signals
Sensors
PointerSensor- Mouse and touch inputKeyboardSensor- Keyboard navigation
Reactivity Model
The Svelte integration uses$effect to sync reactive properties and $state to track changes:
Next Steps
Primitives
Detailed reference for all Svelte primitives
Quick Start
Get started with Svelte integration