Contents

draggable(_:)

Activates this tab as the source of a drag and drop operation. This tab can only be dragged when in the sidebar.

Declaration

@MainActor @preconcurrency func draggable<T>(_ payload: @autoclosure  @escaping () -> T) -> some TabContent<Self.TabValue> where T : Transferable

Parameters

  • payload:

    A closure that returns a single instance or a value conforming to Transferable that represents the draggable data from this tab.

Discussion

Applying the draggable(_:) modifier adds the appropriate gestures for drag and drop to this tab. When a drag operation begins, a rendering of the tab is generated and used as the preview image.

The following example allows the ‘Family’ tab to be dragged and dropped.

TabView {
    Tab("Family", systemImage: "list.bullet") {
        MyFamilyView()
    }
    .draggable(AppSections.family)
}