Gathering detailed insights and metrics for sortablejs-vue3
Gathering detailed insights and metrics for sortablejs-vue3
Gathering detailed insights and metrics for sortablejs-vue3
Gathering detailed insights and metrics for sortablejs-vue3
vue-draggable-plus
Universal Drag-and-Drop Component Supporting both Vue 3 and Vue 2
vue3-sortablejs
A directive for Sortable on Vue 3
element-plus-table-dragable
A directive what used sortablejs to add drag support for element-plus's table component base on vue3.
@xfc/vue3-draggable
draggable component for vue3
npm install sortablejs-vue3
Typescript
Module System
Node Version
NPM Version
75.4
Supply Chain
98.5
Quality
75.9
Maintenance
100
Vulnerability
100
License
Vue (88.77%)
TypeScript (6.11%)
HTML (2.74%)
JavaScript (2.38%)
Total Downloads
1,139,814
Last Day
356
Last Week
14,356
Last Month
62,462
Last Year
665,014
MIT License
400 Stars
100 Commits
24 Forks
8 Watchers
7 Branches
12 Contributors
Updated on Jun 17, 2025
Minified
Minified + Gzipped
Latest Version
1.2.11
Package Id
sortablejs-vue3@1.2.11
Unpacked Size
565.32 kB
Size
492.80 kB
File Count
8
NPM Version
9.8.1
Node Version
18.18.2
Published on
Nov 21, 2023
Cumulative downloads
Total Downloads
2
2
This is a thin wrapper around the great SortableJS library. I had many issues migrating from Vue.Draggable to vue.draggable.next, and after briefly investigating I decided that it was too complicated and a smaller solution was the answer. This wrapper attempts to keep you as close to Sortable as possible.
Vue.Draggable
only supports Vue 2vue.draggable.next
uses the Options API, has multiple open (and afaict useful) pull requests, and had weird bugs/side-effects when I tried and used itshopify/draggable
and vue-shopify-dragable
seemed promising but they don't supported nested componentsYou can see a demo with more complete code at https://sortablejs-vue3.maxleiter.com.
1pnpm add sortablejs-vue3 sortablejs
or
1npm install sortablejs-vue3 sortablejs
<script setup>
(or <script>
):1import { Sortable } from "sortablejs-vue3";
1<template> 2 <main> 3 <Sortable 4 :list="elements" 5 item-key="id" 6 tag="div" 7 :options="options" 8 > 9 <-- The Header and Footer templates below are optional --> 10 <template #header> 11 <header> 12 <h1>SortableJS Vue3 Demo</h1> 13 </header> 14 </template> 15 <template #item="{element, index}"> 16 <div class="draggable" :key="element.id"> 17 {{ element.name }} 18 </div> 19 </template> 20 <template #footer> 21 <footer class="draggable">A footer</footer> 22 </template> 23 </Sortable> 24</template>
list
and item-key
props are necessary. The options
prop is an object that can contain any SortableJS option. You can find a full list of them here: https://github.com/SortableJS/Sortable#options
tag
prop is optional and defaults to div
. It's the HTML node type for the outer element of the included template/slot.list
(Array<any>
, required): your data to listitemKey
(string
| (item) => (string | number | Symbol)
, required): The name of the key present in each item in the list that corresponds to a unique value (to use as the key
)tag
(string
, optional, default = "div"
): The element type to render asoptions
(Object
, false): the SortableJS options minus event handlers (see below)You can listen to Sortable events by adding the listeners to the Sortable
component. For example:
1<Sortable 2 :list="elements" 3 item-key="id" 4 @change="(event: Sortable.SortableEvent) => void" 5 @choose="(event: Sortable.SortableEvent) => void" 6 @unchoose="(event: Sortable.SortableEvent) => void" 7 @start="(event: Sortable.SortableEvent) => void" 8 @end="(event: Sortable.SortableEvent) => void" 9 @add="(event: Sortable.SortableEvent) => void" 10 @update="(event: Sortable.SortableEvent) => void" 11 @sort="(event: Sortable.SortableEvent) => void" 12 @remove="(event: Sortable.SortableEvent) => void" 13 @filter="(event: Sortable.SortableEvent) => void" 14 @move="(event: Sortable.MoveEvent, event2: Event) => void" 15 @move.capture="(event: Sortable.MoveEvent, event2: Event) => boolean | -1 | 1" 16 @clone="(event: Sortable.SortableEvent) => void" 17>
You need to mount any plugins you want outside of the default before importing this library. For example, the below is correct:
1import SortableJs from "sortablejs"; 2import { Swap } from "sortablejs/modular/sortable.core.esm"; 3SortableJs.mount(new Swap()); 4 5import { Sortable } from "sortablejs-vue3";
No changes are necessary to work with Vuex or another store. Just pass store.state.items
as your list. To modify your data you need to manually listen to the events and calculate the new position with event.oldIndex
and event.newIndex
with something like the following:
1const moveItemInArray = <T>(array: T[], from: number, to: number) => { 2 const item = array.splice(from, 1)[0]; 3 nextTick(() => array.splice(to, 0, item)); 4}; 5 6onEnd(event) { moveItemInArray(store.state.items, event.oldIndex, event.newIndex) }
You may also want to see the SortableJS store documentation here.
pnpm
to install dependenciespnpm dev
will start a web server with live reloadingpnpm build
will build the production library filespnpm build:site
will build the demo websiteNo vulnerabilities found.
No security vulnerabilities found.
Last Day
6.3%
356
Compared to previous day
Last Week
-7.7%
14,356
Compared to previous week
Last Month
1.8%
62,462
Compared to previous month
Last Year
65%
665,014
Compared to previous year