@vue-dnd-kit/core
Headless drag-and-drop for Vue 3.
No imposed markup. No hard-coded styles. Just logic.
Features
- Composable API —
makeDraggableandmakeDroppableattach to any element via a template ref. No wrapper components, no render props. - Smart helpers —
suggestSort,suggestSwap,suggestCopy,suggestRemovehandle positioning and array manipulation, so you never have to writesplicelogic by hand. - Multi-drag —
makeSelectionArealets users select multiple items and drag them together. All helpers handle multi-drag natively. - Nested zones — trees, Kanban boards, and nested droppables work out of the box. The library automatically resolves the correct target array based on cursor position.
- Full preview control —
DragPreviewexposes a default slot. Wrap it in<Transition>,AnimatePresencefrom motion-v, GSAP, or anything else. Per-item custom previews viarenderoption. - Keyboard navigation — built-in with configurable keys and step size.
- Async drop — return a
PromisefromonDropto pause the operation while waiting for user confirmation. Preview stays visible until resolved. - Auto-scroll — viewport and individual scrollable containers, with configurable threshold and speed.
- Constraints — restrict movement to an axis or keep the preview inside a container boundary.
- Zero dependencies — Vue 3 as the only peer dependency.
- Tree-shakeable — import only what you use.
- Full TypeScript — everything is typed.
Install
npm install @vue-dnd-kit/core
# or
yarn add @vue-dnd-kit/core
# or
pnpm add @vue-dnd-kit/core
Peer dependency: Vue ^3.5
Quick start
<!-- App.vue -->
<script setup lang="ts">
import { ref, useTemplateRef } from 'vue';
import { DnDProvider, makeDroppable } from '@vue-dnd-kit/core';
import SortableItem from './SortableItem.vue';
const items = ref(['One', 'Two', 'Three', 'Four']);
const zoneRef = useTemplateRef<HTMLElement>('zone');
makeDroppable(zoneRef, {
events: {
onDrop(e) {
const r = e.helpers.suggestSort('vertical');
if (r) items.value = r.targetItems as string[];
},
},
}, () => items.value);
</script>
<template>
<DnDProvider>
<div ref="zone" class="list">
<SortableItem
v-for="(item, i) in items"
:key="item"
:index="i"
:items="items"
>
{{ item }}
</SortableItem>
</div>
</DnDProvider>
</template>
<!-- SortableItem.vue -->
<script setup lang="ts">
import { useTemplateRef } from 'vue';
import { makeDraggable } from '@vue-dnd-kit/core';
const props = defineProps<{ index: number; items: string[] }>();
const el = useTemplateRef<HTMLElement>('el');
const { isDragging } = makeDraggable(el, {}, () => [props.index, props.items]);
</script>
<template>
<div ref="el" :style="{ opacity: isDragging ? 0 : 1 }">
<slot />
</div>
</template>
Packages
| Package | Description |
|---|---|
@vue-dnd-kit/core |
Core library — composables, DnDProvider, DragPreview |
@vue-dnd-kit/utilities |
Extra utility helpers |
Documentation
Full docs with live examples: zizigy.github.io/vue-dnd-kit
Covers: sorting, swap, copy, multi-drag, trees, Kanban, custom preview, animations, keyboard navigation, async drop, constraints, auto-scroll and more.
Contributing
Issues and pull requests are welcome. For larger changes, please open an issue first to discuss the approach.
💛 Support
If vue-dnd-kit saves you time, consider supporting the project — it helps keep development going.
License
Related Packages
Utilities for Vue DnD Kit - a lightweight Vue 3 library for building performant...
Drag'n'Drop with multiple Elements. Provides a vue directive for draggable eleme...
A simple kanban board where the items can be dragged and dropped from the list....
Version History
| Version | Released | License |
|---|---|---|
| 2.4.7 | MIT | |
| 2.4.6 | MIT | |
| 2.4.5 | MIT | |
| 2.4.4 | MIT | |
| 2.4.3 | MIT | |
| 2.4.2 | MIT | |
| 2.4.1 | MIT | |
| 2.4.0 | MIT | |
| 2.3.1 | MIT | |
| 2.3.0 | MIT | |
| 2.2.0 | MIT | |
| 2.1.5 | MIT | |
| 2.1.4 | MIT | |
| 2.1.3 | MIT | |
| 2.1.2 | MIT | |
| 2.1.1 | MIT | |
| 2.1.0 | MIT | |
| 2.0.12 | MIT | |
| 2.0.11 | MIT | |
| 2.0.10 | MIT | |
| 2.0.9 | MIT | |
| 2.0.8 | MIT | |
| 2.0.7 | MIT | |
| 2.0.6 | MIT | |
| 2.0.5 | MIT | |
| 2.0.4 | MIT | |
| 2.0.3 | MIT | |
| 2.0.2 | MIT | |
| 2.0.1 | MIT | |
| 2.0.0 | MIT |
Showing the latest 30 of 78. See every release on npm
Pre-releases (46)
| Version | Released | License |
|---|---|---|
| 2.0.0-alpha10 | MIT | |
| 2.0.0-alpha9 | MIT | |
| 2.0.0-alpha8 | MIT | |
| 2.0.0-alpha7 | MIT | |
| 2.0.0-alpha6 | MIT | |
| 2.0.0-alpha5 | MIT | |
| 2.0.0-alpha4 | MIT | |
| 2.0.0-alpha3 | MIT | |
| 2.0.0-alpha2 | MIT | |
| 2.0.0-alpha1 | MIT | |
| 0.3.0-beta | MIT | |
| 0.2.9-beta | MIT | |
| 0.2.8-beta | MIT | |
| 0.2.7-beta | MIT | |
| 0.2.6-beta | MIT | |
| 0.2.5-beta | MIT | |
| 0.2.4-beta | MIT | |
| 0.1.5-beta | MIT | |
| 0.1.4-beta | MIT | |
| 0.1.3-beta | MIT | |
| 0.1.2-beta | MIT | |
| 0.1.1-beta | MIT | |
| 0.0.49-beta | MIT | |
| 0.0.48-beta | MIT | |
| 0.0.47-beta | MIT | |
| 0.0.46-beta | MIT | |
| 0.0.45-beta | MIT | |
| 0.0.44-beta | MIT | |
| 0.0.42-beta | MIT | |
| 0.0.41-beta | MIT |
Showing the latest 30 of 46. See every release on npm