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 DragAndDropContainers you will need to:
- Set the
DragAndDropcomponent'stypeprop to becanvas. - Add two or more
DragAndDropContainercomponents inside a singleDragAndDropcomponent - Give each
DragAndDropContainera unique ID that matches the container key used in the data passed to theDragAndDropcomponent'sitemsprop. - The
DragAndDropcomponent's child works as a function that will provide the sorted items data. - You can use the unique container id to render the
DragAndDropItems 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
DragAndDropcomponent'sitemsprop. - Use the
DragAndDropcomponent'sonDragEndprop to set the items back into state when items are sorted. - Update the item state using the input's
onChangeevent 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
DragAndDropcomponent'sitemsprop. - Use the
DragAndDropcomponent'sonDragEndprop 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