Vue Drag and drop

Vue Bootstrap 5 Drag and drop plugin

Drag and Drop plugin built with Bootstrap 5 and Vue 3. Examples of draggable list, cards, tables, grid, buttons. Available sort, copy, scroll, disable, delay, nested & other options.

Note: Read the API tab to find all available options and advanced customization


Draggable basic example

Create draggable element with MDBDraggable component.

Drag me!


Custom container

If you want to have your draggable component in a container, just add container property with selector to your component. .

Drag me!


Blocked axis

Thanks to blockXAxis property or blockYAxis property you can disable x or y axis. .

Drag me!

Drag me!


Delay

You can set delay of starting dragging by adding delay property with miliseconds value. .

Drag me after one second!


Disabled

You can set your draggable element as disabled by adding disabled property. .

Disabled


Custom drag button

By adding dragHandle with selector you can set drag handler of your element. Note that drag handler has to be inside an element.

Drag only on button!


Scrolling option

When your draggable element is inside a scrollable container your component will scroll its while you will be near the edge.

Drag!


Sortable basic example

Make your list sortable with MDBSortable component and sortable items with MDBSortableItem.

Item 1
Item 2
Item 3
Item 4
Item 5

Horizontal example

Sortable list will create no matter how rotated it is.

Item 1
Item 2
Item 3
Item 4
Item 5

Grid example

Sortable list works with grid as well.

Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
Item 7
Item 8
Item 9
Item 10
Item 11
Item 12

Multiple tables

You can connect your list with other by passing its reference to the connectedList property.

To do

Item 1
Item 2
Item 3
Item 4
Item 5
Disabled

Done

Item 6
Item 7
Item 8
Item 9
Item 10

Coping items

By adding copy property you can copy your items to connected table.

Elements

Item 1
Item 2
Item 3
Item 4
Item 5

Copy

Item 6
Item 7
Item 8
Item 9
Item 10

Conditions

You can set your own conditions about permission to sending or coping items to connected table by adding your custom function with true / false return to enterPredicate property.

Numbers

1
2
3
4
5

Only odd numbers

7

Disabled sorting

By adding sorting with false value you can disable sorting in table.

Sorting available

Item 1
Item 2
Item 3
Item 4
Item 5

Sorting not available

item 6
item 7

Nested

By adding itemClass you can set what class has to be in your list item to make them sortable. Thanks to that you can make nested lists.

To do

Item 1
Item 2
Item 3
Item 4
Item 5

Done

item 6
item 7
item 8
item 9

Vue Drag and drop - API


Import


        import { MDBCalendar, dayjs } from "mdb-vue-calendar";
      

Properties

Draggable

Name Type Default Description
blockXAxis Boolean false Defines whether 'x' axis is blocked or not
blockYAxis Boolean false Defines whether 'y' axis is blocked or not
container String body Defines container of dragging element
delay Number 0 Defines how long will deley exist before element starts to drag
disabled Boolean false Defines whether element is able to drag or not
disabled Boolean false Defines whether element is able to drag or not
dragHandle String '' Defines drag handler of the element. Note, handler has to be inside of the dragging element
draggingClass String dragging Defines class which is using during dragging of the element
scrollPixels Number 40 If container is scrollable, defines distance from edges where scrolling will begin
tag Stering 'div' Defines element tag

Sortable

Name Type Default Description
animationDuration Number 300 Defines duration of sliding and returning animations
classes String '' Defines custom classes for sortable list wrapper
connectedList Ref element null Defines list which you want to connect with
copy Boolean false Defines whether you want to copy elements from one list to another or send them instead
dragHandle String '' Defines drag handler of the element for nested lists. Note, handler has to be inside of the dragging element
enterPredicate Function () => true Defines function which check access between tables
itemClass String sortable-item Defines class name for sortable items.
sorting Boolean true Defines whether list is able to sort or not
tag Stering 'div' Defines element tag

Sortable Item

Name Type Default Description
disabled Boolean false Defines whether element is allowed to drag or not
classes String '' Defines custom classes for sortable list wrapper
dragHandle String '' Defines drag handler of the element. Note, handler has to be inside of the dragging element
itemClass String sortable-item Defines class name for sortable items.
value String , Number Defines custom value for access between lists
tag Stering 'div' Defines element tag

Methods

Draggable

Name Description
resetPosition Return original position of the element

Sortable

Name Description
addItem Adds element to the sortable list. You can set position in the list of your new item by adding index number. Note: If you did not insert an index number, your element would append at the end of the list.

Events

Draggable

Name Description
start Emitted when an element is started dragging
end Emitted when an element is ended dragging
move Emitted when an element is dragging

Sortable

Name Description
move Emitted when one of the itmes from list changed its position.
exit Emitted when one of the items from list will enter to connected table.
start Emitted when one of the items from list is dragged.