<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/reorderContainer(for:in:isEnabled:move:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE16reorderContainer3for2in9isEnabled4moveQrqd__m_qd_0_mSbyAA17ReorderDifferenceVy2IDQyd__qd_0_Gcts12IdentifiableRd__SHRd_0_s8SendableRd_0_sAoLRQr0_lF"
  },
  "title" : "reorderContainer(for:in:isEnabled:move:)"
}
-->

# reorderContainer(for:in:isEnabled:move:)

Defines a container of reorderable views, with a type you specify to
identify sections.

```
nonisolated func reorderContainer<Item, CollectionID>(for item: Item.Type, in collectionID: CollectionID.Type, isEnabled: Bool = true, move: @escaping (ReorderDifference<Item.ID, CollectionID>) -> ()) -> some View where Item : Identifiable, CollectionID : Hashable, CollectionID : Sendable, Item.ID : Sendable
```

## Parameters

`item`

The type of reorderable items in the container.

`collectionID`

The type used to identify collections of reorderable
items in the container.

`isEnabled`

Whether the container allows reordering.

`move`

A closure that provides the change at the end of a session.

## Discussion

Declare this modifier on your list, stack, grid, or custom layout to
define a reorderable container. Then, apply
[`reorderable(collectionID:)`](/documentation/SwiftUI/DynamicViewContent/reorderable(collectionID:)) to the content of
your container to make those views reorderable.

Use this overload if your container contains multiple collections. If
your container only has a single collection, use the convenience
[`reorderContainer(for:isEnabled:move:)`](/documentation/SwiftUI/View/reorderContainer(for:isEnabled:move:)) modifier.

A person can lift a reorderable view within the container using a drag
gesture. As they lift the item, the system puts a placeholder view in
its place to indicate where the view can drop. As they move the item
through the container, the position of the placeholder updates to
reflect which view the person drags over. When they drop the view, the
system calls the `move` closure and provides the change.

The system provides the change as a difference to the closure. The
difference contains the identifiers of items to move, in the order that
the person selected them. It also contains a destination value, which
indicates where to insert the item or items.

The following example shows a list of reminder views that a person can
move to reorder inside and between each [`Section`](/documentation/SwiftUI/Section) in the [`List`](/documentation/SwiftUI/List):

```
struct ContentView: View {
    @State private var model = ReminderModel()

    var body: some View {
        List {
            ForEach(model.sections) { section in
                Section(section.name) {
                    ForEach(section.reminders) { reminder in
                        ReminderView(reminder)
                    }
                    .reorderable(collectionID: section.id)
                }
            }
        }
        .reorderContainer(
            for: Reminder.self, in: ReminderModel.Section.ID.self
        ) { difference in
            model.apply(difference: difference)
        }
    }
}
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)