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
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
.
Horizontal example
Sortable list will create no matter how rotated it is.
Grid example
Sortable list works with grid as well.
Multiple tables
You can connect your list with other by passing its reference to the
connectedList
property.
To do
Done
Coping items
By adding copy
property you can copy your items to
connected table.
Elements
Copy
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
Only odd numbers
Disabled sorting
By adding sorting
with false
value you can
disable sorting in table.
Sorting available
Sorting not available
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
Done
Drag and drop - API
Import
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 |
blockXAxis
|
Boolean | false |
Defines whether 'x' axis is blocked or not |
blockYAxis
|
Boolean | false |
Defines whether 'y' axis is blocked or not |
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 |
---|---|---|---|
blockXAxis
|
Boolean | false |
Defines whether 'x' axis is blocked or not |
blockYAxis
|
Boolean | false |
Defines whether 'y' axis is blocked or not |
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. |
end
|
Emitted when dragging one of the items from list have been ended. A new structure of list is available with HTML node which is property of the event. |