Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vuedraggable

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vuedraggable

draggable component for vue

  • 2.11.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
745K
increased by0.26%
Maintainers
1
Weekly downloads
 
Created

What is vuedraggable?

vuedraggable is a Vue.js component that allows you to create draggable and sortable lists with ease. It is based on the Sortable.js library and provides a simple way to implement drag-and-drop functionality in your Vue applications.

What are vuedraggable's main functionalities?

Basic Draggable List

This code sample demonstrates a basic draggable list using vuedraggable. The list items can be dragged and reordered.

<template>
  <draggable v-model="items">
    <div v-for="item in items" :key="item.id">{{ item.name }}</div>
  </draggable>
</template>

<script>
import draggable from 'vuedraggable';

export default {
  components: { draggable },
  data() {
    return {
      items: [
        { id: 1, name: 'Item 1' },
        { id: 2, name: 'Item 2' },
        { id: 3, name: 'Item 3' }
      ]
    };
  }
};
</script>

Draggable with Handle

This code sample shows how to use a handle for dragging items. Only the handle (represented by '::') can be used to drag the items.

<template>
  <draggable v-model="items" handle=".handle">
    <div v-for="item in items" :key="item.id">
      <span class="handle">::</span> {{ item.name }}
    </div>
  </draggable>
</template>

<script>
import draggable from 'vuedraggable';

export default {
  components: { draggable },
  data() {
    return {
      items: [
        { id: 1, name: 'Item 1' },
        { id: 2, name: 'Item 2' },
        { id: 3, name: 'Item 3' }
      ]
    };
  }
};
</script>

Nested Draggable Lists

This code sample demonstrates how to create nested draggable lists. Both parent and child items can be dragged and reordered independently.

<template>
  <draggable v-model="parentItems">
    <div v-for="parent in parentItems" :key="parent.id">
      <div>{{ parent.name }}</div>
      <draggable v-model="parent.children">
        <div v-for="child in parent.children" :key="child.id">{{ child.name }}</div>
      </draggable>
    </div>
  </draggable>
</template>

<script>
import draggable from 'vuedraggable';

export default {
  components: { draggable },
  data() {
    return {
      parentItems: [
        { id: 1, name: 'Parent 1', children: [
          { id: 11, name: 'Child 1' },
          { id: 12, name: 'Child 2' }
        ]},
        { id: 2, name: 'Parent 2', children: [
          { id: 21, name: 'Child 3' },
          { id: 22, name: 'Child 4' }
        ]}
      ]
    };
  }
};
</script>

Other packages similar to vuedraggable

Keywords

FAQs

Package last updated on 11 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc