dropConfiguration

Configures a drop session.

View ModifieriOS 27.0+macOS 26.0+visionOS 27.0+dropConfiguration(_:) in SwiftUI

Declaration

React
compose().dropConfiguration({
  returns: SwiftUI.DropConfiguration,
  perform?: (arg0: SwiftUI.DropSession) => void,
})
Swift
nonisolated func dropConfiguration(
    _ configuration: @escaping (DropSession) -> DropConfiguration
) -> some View

Parameters

Return value

A view that configures a drop session in a way, described

Discussion

Below is an example of a view that accepts drop of Image type. The view prefers drop operation move in a case when the source supports it (the source will remove the images from its storage after the drop operation). If the source does not support moving images, the destination will make copies.

       ExampleView()
           .dropDestination(for: Image.self) { images, _ in
               process(images)
           }
           .dropConfiguration { dropSession in
               if dropSession.suggestedOperations.contains(.move) {
                   return DropConfiguration(operation: .move)
               }
               return DropConfiguration(operation: .copy)
           }

frequently to allow specifying different operations for different drop locations in a view. Do not perform any expensive calculations in it.

of a drop session. by the return value of the configuration parameter.

See also

More in Drag and drop.