androidx.compose.foundation.draganddrop

dragAndDropSource

Function · from org.jetbrains.compose.foundation:foundation:1.12.2

No hand-written docs yet.

A Modifier that allows an element it is applied to be treated like a source for drag and drop operations. It displays the element dragged as a drag shadow.

Form 1

fun Modifier.dragAndDropSource(
    transferData: (Offset) -> DragAndDropTransferData?,
): Modifier

transferData: (Offset) -> DragAndDropTransferData?RequiredSince 1.8

A function that receives the current offset of the drag operation and returns the DragAndDropTransferData to be transferred. If null is returned, the drag and drop transfer won't be started.

With drawDragDecoration

fun Modifier.dragAndDropSource(
    drawDragDecoration: DrawScope.() -> Unit,
    transferData: (Offset) -> DragAndDropTransferData?,
): Modifier

drawDragDecoration: DrawScope.() -> UnitRequired

provides the visual representation of the item dragged during the drag and drop gesture.

Same as above: transferData.

Library docs

A Modifier that allows an element it is applied to be treated like a source for drag and drop operations. It displays the element dragged as a drag shadow.

Learn how to use Modifier.dragAndDropSource: