Drag and drop

Angular Bootstrap 5 Drag and drop plugin

Drag and Drop plugin built with Bootstrap 5. 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

Try out MDB Drag & Drop Builder


Draggable basic example

By adding mdbDraggable directive you can make your custom element draggable.

Drag me!


Custom container

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

Drag me!


Blocked axis

Thanks to [lockAxis] input you can disable x or y axis.

Drag me!

Drag me!


Delay

You can set deley of starting dragging by adding [delay] input with miliseconds value.

Drag me after one second!


Disabled

You can set your draggable element as disabled by adding [disabled] with true value.

Disabled


Custom drag button

By adding [handle] input with element or element 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

By adding mdbSortableContainer directive you can add sortable functionality to the items in a container. Note, only elements with mdbDraggable directive name will be able to sort.

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

By using [containers] input you can connect your list with other container.

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] input with value true 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] input.

Numbers

1
2
3
4
5

Only odd numbers

7

Disabled sorting

By adding data-mdb-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

To do

Item 1
Item 2
Item 3
Item 4
Item 5

Done

item 6
item 7
item 8
item 9

Drag and drop - API


Import


        import { MdbDragAndDropModule } from 'mdb-angular-drag-and-drop';
        …
        @NgModule ({
          ...
          imports: [MdbDragAndDropModule],
          ...
        })
      

Inputs

mdbDraggable

Name Type Default Description
boundaryElement HTMLElement | String body Defines boundary container for dragged element
copy Boolean false Defines if dragged element should be moved or copied to new container
data any - Defines draggable element data
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
handle HTMLElement | String - Defines drag handler of the element. Note, handler has to be inside of the dragging element
lockAxis 'x' | 'y' | null null Defines whether 'x' or 'y' axis is blocked

mdbSortableContainer

Name Type Default Description
containers MdbSortableContainer | String [] Defines list of connected containers
enterPredicate Function () => true Defines function which check access between tables
sortingDisabled Boolean false Defines whether list is able to sort or not

Outputs

mdbSortableContainer

Name Description
(itemDrop) Emitted on element drop in container