Headless drag-and-drop for Vue 3.
No imposed markup. No hard-coded styles. Just logic.
Documentation · Examples · Changelog
makeDraggable and makeDroppable attach to any element via a template ref. No wrapper components, no render props.suggestSort, suggestSwap, suggestCopy, suggestRemove handle positioning and array manipulation, so you never have to write splice logic by hand.makeSelectionArea lets users select multiple items and drag them together. All helpers handle multi-drag natively.DragPreview exposes a default slot. Wrap it in <Transition>, AnimatePresence from motion-v, GSAP, or anything else. Per-item custom previews via render option.Promise from onDrop to pause the operation while waiting for user confirmation. Preview stays visible until resolved.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
<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>
<SortableItem
v-for="(item, i) in items"
:key="item"
:index="i"
:items="items"
>
{{ item }}
</SortableItem>
</DnDProvider>
</template>
<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>
<slot />
</template>
| Package | Description |
|---|---|
@vue-dnd-kit/core |
Core library — composables, DnDProvider, DragPreview |
@vue-dnd-kit/utilities |
Extra utility helpers |
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.
Issues and pull requests are welcome. For larger changes, please open an issue first to discuss the approach.
If vue-dnd-kit saves you time, consider supporting the project — it helps keep development going.
$ claude mcp add vue-dnd-kit \
-- python -m otcore.mcp_server <graph>