🎯 Modern drag & drop solution for Vue 3 applications. Simple API, powerful features, zero dependencies.
翻譯準備中
正在載入完整 README。
檢視完整 README ↗Drag and drop for Vue 3. Sortable lists, kanban boards, trees, multi-drag and drop zones — animated, keyboard-ready and accessible out of the box, in your own markup.
Documentation · Examples · API · Releases
npm i @vue-dnd-kit/core
# or
yarn add @vue-dnd-kit/core
# or
pnpm add @vue-dnd-kit/core
With Nuxt, add the module: it registers the provider and auto-imports the composables.
npx nuxi module add @vue-dnd-kit/nuxt
Requirements: Vue 3.5+. Chrome and Edge 104+, Safari 15.4+, Firefox 104+.
A sortable list in three files: a provider, a list and its rows.
<!-- App.vue: the provider goes around the components that drag -->
<script setup lang="ts">
import { DnDProvider } from '@vue-dnd-kit/core';
import TaskList from './TaskList.vue';
</script>
<template>
<DnDProvider>
<TaskList />
</DnDProvider>
</template>
<!-- TaskList.vue -->
<script setup lang="ts">
import { ref, useTemplateRef } from 'vue';
import { makeSortableList } from '@vue-dnd-kit/core';
import TaskRow from './TaskRow.vue';
const tasks = ref([
{ id: 1, title: 'Sketch the board' },
{ id: 2, title: 'Write the docs' },
{ id: 3, title: 'Ship v3' },
]);
const listRef = useTemplateRef<HTMLElement>('list');
// `items` is the draft: it reorders while you drag. On drop, `tasks` gets the new order.
const { items } = makeSortableList(listRef, { items: tasks });
</script>
<template>
<ul ref="list">
<TaskRow v-for="task in items" :key="task.id" :task="task" />
</ul>
</template>
<!-- TaskRow.vue -->
<script setup lang="ts">
import { useTemplateRef } from 'vue';
import { makeSortableItem } from '@vue-dnd-kit/core';
const props = defineProps<{ task: { id: number; title: string } }>();
const el = useTemplateRef<HTMLElement>('el');
makeSortableItem(el, { item: () => props.task });
</script>
<template>
<li ref="el">{{ task.title }}</li>
</template>
Drag a row — or Tab to it, press Space, move it with the arrows and press Space again.
| Package | What it is |
|---|---|
@vue-dnd-kit/core | The library: DnDProvider, sortable lists and trees, draggables, drop zones, drag areas, selection. |
@vue-dnd-kit/nuxt | Nuxt module: registers the provider and auto-imports the composables and types. |
@vue-dnd-kit/actions | Programmatic drags: "move up" buttons, menus, tours and tests, with the normal animations. |
@vue-dnd-kit/devtools | A Vue DnD Kit tab in Vue DevTools and Nuxt DevTools. |
The repository ships an agent skill: assistants such as Claude Code learn the model of the library, its rules and its pitfalls.
npx skills add ZiZIGY/vue-dnd-kit
Issues and pull requests are welcome. For larger changes, please open an issue first to discuss the approach. CONTRIBUTING.md explains the repository, the commands and how releases work.
If vue-dnd-kit saves you time, consider supporting the project — it helps keep development going.