Delete Disabled
Adds a condition for whether the view’s view hierarchy is deletable.
Platform Compatibility
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?
More List Components
View allOutline Group
A structure that computes views and disclosure groups on demand from an underlying collection of tree-structured, identified data.
Disclosure Group
A view that shows or hides another content view, based on the state of a disclosure control.
Section Index Label and Visibility
Sets the label that is used in a section index to point to this section, typically only a single character long. Changes the visibility of the list section index.
Explore Other Components
Browse allViewThatFits
A view that adapts to the available space by providing the first child view that fits.
NavigationLinkPickerStyle
A picker style represented by a navigation link that presents the options by pushing a List-style picker view.
Upgrade Only Subscription Store View
Creates a view that loads all subscriptions from a subscription group but displays only the higher-level ones. In this case, the VIP Kitty Pass is already active, which is why only the higher-tier Royal Kitty Pass is displayed.