reorderable

Enables reordering of views from this content inside the scope of a reorderable container modifier.

DynamicViewContent ModifieriOS 27.0+macOS 27.0+watchOS 27.0+visionOS 27.0+

Overloads

2 ways to call compose().reorderable(). Each is one SwiftUI overload, picked by the arguments you pass.

React
compose().reorderable()
Swift
nonisolated func reorderable() -> some DynamicViewContent<Self.Data>

Discussion

Declare this modifier on DynamicViewContent within a reorderable container to allow people to reorder the items in the content using a system drag gesture. A reorderable container is a list, stack, grid, or custom layout that you define with the View.reorderContainer(for:in:isEnabled:move:) modifier.

Use this modifier when you have a single collection in the container. If your container has multiple collections, use DynamicViewContent.reorderable(collectionid:) instead.

The following example shows a list of landmark views that a person can move to reorder inside the VStack:

struct ContentView: View {
    @State private var landmarks: [Landmark] = []

    var body: some View {
        VStack {
            ForEach(landmarks) { landmark in
                LandmarkView(landmark)
            }
            .reorderable()
        }
        .reorderContainer(for: Landmark.self) { difference in
            apply(difference: difference)
        }
    }
}

See also

More in DynamicViewContent modifiers.