Drag and drop
React 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
Draggable basic example
By using MDBDraggable
component you can make your custom element
draggable.
Drag me!
Custom container
If you want to have your draggable component in a container, add
container
property with the reference to your element.
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
By using MDBSortable
you will make your list sortable.
Note, only MDBSortableElement
elements will be
able to sort.
Horizontal example
Sortable list will create no matter how rotated it is.
Grid example
Sortable list works with grid as well.
Drag and drop - API
Import
Properties
MDBDraggable
Name | Type | Default | Description | Example |
---|---|---|---|---|
className
|
string | '' |
Adds a custom class to the MDBDraggable |
<MDBDraggable className="class" />
|
blockXAxis
|
boolean | false |
Defines whether 'x' axis is blocked or not |
<MDBDraggable blockXAxis />
|
blockYAxis
|
boolean | false |
Defines whether 'y' axis is blocked or not |
<MDBDraggable blockYAxis />
|
container
|
React.RefObject<any> | body |
Defines container of dragging element |
<MDBDraggable container={container} />
|
delay
|
number | 0 |
Defines how long will deley exist before element starts to drag |
<MDBDraggable delay={500} />
|
disabled
|
boolean | false |
Defines whether element is able to drag or not |
<MDBDraggable disabled />
|
dragHandle
|
React.RefObject<any> |
|
Defines drag handler of the element. Note, handler has to be inside of the dragging element |
<MDBDraggable dragHandle={dragElement} />
|
draggingClass
|
string | dragging |
Defines class which is using during dragging of the element |
<MDBDraggable draggingClass='test' />
|
scrollPixels
|
number | 40 |
If container is scrollable, defines distance from edges where scrolling will begin |
<MDBDraggable scrollPixels={600} />
|
tag
|
string | 'div' |
Defines a tag type for the MDBDraggable |
<MDBDraggable tag='span' />
|
MDBSortable
Name | Type | Default | Description | Example |
---|---|---|---|---|
className
|
string | '' |
Add custom class to the MDBSortable |
<MDBSortable className="class" />
|
tag
|
string | 'div' |
Defines a tag type for the MDBSortable |
<MDBSortable tag='span' />
|