---
title: "draggable(_:id:item:containerNamespace:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/view/draggable(_:id:item:containernamespace:)"
---

# draggable(_:id:item:containerNamespace:)

Activates this view as the source of a drag and drop operation, allowing to provide optional payload and specify the namespace of the drag container this view belongs to.

## Declaration

```swift
nonisolated func draggable<Item, ItemID>(_ itemType: Item.Type = Item.self, id: KeyPath<Item, ItemID>, item: @autoclosure @escaping () -> Item?, containerNamespace: Namespace.ID? = nil) -> some View where Item : Transferable, ItemID : Hashable, ItemID : Sendable

```

## Parameters

- `itemType`: A type of the dragged item.
- `id`: An identifier of an item.
- `item`: A closure that returns a single instance or a value conforming to doc://com.apple.documentation/documentation/CoreTransferable/Transferable that represents the draggable data from this view.
- `containerNamespace`: A namespace of the associated drag container.

## Return Value

Return Value A view that activates this view as the source of a drag and drop operation, beginning with user gesture input.

## Discussion

Discussion Applying the draggable(_:containerNamespace_:) modifier adds the appropriate gestures for drag and drop to this view. When a drag operation begins, a rendering of this view is generated and used as the preview image. To customize the default preview, apply a contentShape(_:_:eoFill:) with a dragPreview kind. For example, you can change the preview’s corner radius or use a nested view as the preview.

## See Also

### Moving transferable items

- [draggable(_:)](swiftui/view/draggable(_:).md)
- [draggable(_:preview:)](swiftui/view/draggable(_:preview:).md)
- [draggable(_:containerNamespace:_:)](swiftui/view/draggable(_:containernamespace:_:).md)
- [draggable(_:id:containerNamespace:_:)](swiftui/view/draggable(_:id:containernamespace:_:).md)
- [draggable(_:item:containerNamespace:)](swiftui/view/draggable(_:item:containernamespace:).md)
- [draggable(containerItemID:containerNamespace:)](swiftui/view/draggable(containeritemid:containernamespace:).md)
