DragAndDrop
Result
Loading...
Live Editor
Horizontal dragging
The DragAndDrop component supports setting the type prop to column
which will lock the drag behavior to the horizontal axis and change the drag icon. The DragAndDropContainer styles will need to be updated to incorporate a preferred column style.
Result
Loading...
Live Editor
Theme
Setting the theme
prop to border
displays a border around each DragAndDropItem
.
Result
Loading...
Live Editor
Multiple DragAndDropContainers
To allow items to move between multiple DragAndDropContainer
s you will need to:
- Set the
DragAndDrop
component'stype
prop to becanvas
. - Add two or more
DragAndDropContainer
components inside a singleDragAndDrop
component - Give each
DragAndDropContainer
a unique ID that matches the container key used in the data passed to theDragAndDrop
component'sitems
prop. - The
DragAndDrop
component's child works as a function that will provide the sorted items data. - You can use the unique container id to render the
DragAndDropItem
s into eachDragAndDropContainer
.
Result
Loading...
Live Editor
Controlled state for Inputs inside DragAndDropItems
To use form inputs inside the DragAndDropItems
you will need to:
- Add your items data into state.
- Pass the items state down to the
DragAndDrop
component'sitems
prop. - Use the
DragAndDrop
component'sonDragEnd
prop to set the items back into state when items are sorted. - Update the item state using the input's
onChange
event which will cause a re-render with the new data.
Result
Loading...
Live Editor
Removable items
To be able to delete DragAndDropItems
you will need to:
- Add your items data into state.
- Pass the items state down to the
DragAndDrop
component'sitems
prop. - Use the
DragAndDrop
component'sonDragEnd
prop to set the items back into state when items are sorted. - When you custom delete button is clicked remove the item from state.
Result
Loading...
Live Editor