Interactive previews iPhone
EditButton
A button that toggles the edit mode environment value
Platform Compatibility
iOS 13.0+ iPadOS 13.0+ visionOS 1.0+
Tags
SwiftUI Code
@Environment(\.editMode) private var editMode
@State private var name = "Foo"
var body: some View {
HStack {
if editMode?.wrappedValue.isEditing == true {
TextField("Name", text: $name)
} else {
Text(name)
}
EditButton()
}
}Found an issue or have a suggestion?
Created: June 3, 2025Updated: December 27, 2025
More Button Components
View allGlass Button Styles
A button style that applies glass border artwork based on the button’s context
Explore Other Components
Browse allCustom Session Async URL Image
A modifier that adds a URL session for asynchronous images contained in the view to use when fetching image data.
Custom Icon Store View
Creates a view to load a collection of products from the App Store using product identifiers, and merchandise them using a custom image.
System Image Label
Creates a label with a system icon image and a title generated from a localized string.
Subscription Store View
Creates a view that loads subscriptions based on a collection of product identifiers, and merchandises them with automatic marketing content.