<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/DynamicViewContent/onDelete(perform:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI18DynamicViewContentPAAE8onDelete7performQry10Foundation8IndexSetVcSg_tF"
  },
  "title" : "onDelete(perform:)"
}
-->

# onDelete(perform:)

Sets the deletion action for the dynamic view. You must delete the
corresponding item within `action`, as it will be called after the
row has already been removed from the [`List`](/documentation/SwiftUI/List).

```
nonisolated func onDelete(perform action: Optional<(IndexSet) -> Void>) -> some DynamicViewContent
```

## Parameters

`action`

The action that you want SwiftUI to perform when
elements in the view are deleted. SwiftUI passes a set of indices to the
closure that’s relative to the dynamic view’s underlying collection of
data.

## Return Value

A view that calls `action` when elements are deleted from the
original view.

---

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)