Delete Disabled
Adds a condition for whether the view’s view hierarchy is deletable.
Platform Compatibility
iOS 13.0+ iPadOS 13.0+ macOS 10.15+ watchOS 6.0+ tvOS 13.0+ visionOS 1.0+
Tags
SwiftUI Code
let items = ["Foo", "Bar"]
var body: some View {
List {
Section("Header") {
ForEach(items, id: \.self) { item in
Text(item)
.deleteDisabled(item == "Foo")
}.onDelete { _ in
action()
}
}
}
.environment(\.editMode, .constant(.active))
}
Found an issue or have a suggestion?
Created: August 10, 2025Updated: August 10, 2025