Vue Smooth DnD is a lightweight and performant Vue.js wrapper library for the underlying `smooth-dnd` core library. Currently at version 0.8.1, it provides comprehensive drag-and-drop and sortable functionalities for Vue applications. The library exposes Vue components like `Container` and `Draggable`, which allow developers to easily implement interactive UIs with features such as vertical or horizontal orientation, different drag behaviors (move, copy, drop-zone), drag handles, and auto-scrolling. While a specific release cadence isn't detailed, its evolution is closely tied to the `smooth-dnd` project. It stands out by offering a highly configurable, efficient solution, making it suitable for a wide array of user interaction requirements within the Vue ecosystem.
npm install vue-smooth-dndVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates a basic sortable list using `Container` and `Draggable` components, handling drops with the `onDrop` event and a utility `applyDrag` function to update the item order.
Always bind an `@drop` listener to the `Container` and manually update the `items` array in your component's data or state management store using the `dropResult`.
Ensure that every element or component you want to be draggable inside a `Container` is nested directly inside a `<Draggable>` tag, e.g., `<Container><Draggable><div>Item</div></Draggable></Container>`.
Add `:group-name="'my-group'"` to all `Container` components that should allow items to be moved between them. You can also customize this behavior with the `shouldAcceptDrop` prop.
If you need to render the `Container` as a specific HTML element or with additional attributes, use the `tag` prop. For complex cases, provide an object: `:tag="{value: 'table', props: {class: 'my-table'}}"`.Verify that the `@drop` event is correctly bound to the `Container` component and that the `onDrop` method receives the `dropResult` object as its argument. Ensure `dropResult` is not accidentally reassigned or ignored.
Ensure your `onDrop` method correctly processes the `dropResult` by using a utility like `applyDrag` to create a *new* array with the updated order/content and assigns it back to your reactive `items` data property (`this.items = newItemsArray`). Direct mutation of the original array might not trigger reactivity in some Vue versions or setups.
Ensure you have `import { Container, Draggable } from 'vue-smooth-dnd';` at the top of your script, and that both `Container` and `Draggable` are listed in the `components` option of your Vue component: `components: { Container, Draggable }`.