<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/EnvironmentValues/editMode",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI17EnvironmentValuesVAAE8editModeAA7BindingVyAA04EditF0OGSgvp"
  },
  "title" : "editMode"
}
-->

# editMode

An indication of whether the user can edit the contents of a view
associated with this environment.

```
var editMode: Binding<EditMode>? { get set }
```

## Discussion

Read this environment value to receive a optional binding to the
edit mode state. The binding contains an [`EditMode`](/documentation/SwiftUI/EditMode) value
that indicates whether edit mode is active, and that you can use to
change the mode. To learn how to read an environment
value, see [`EnvironmentValues`](/documentation/SwiftUI/EnvironmentValues).

Certain built-in views automatically alter their appearance and behavior
in edit mode. For example, a [`List`](/documentation/SwiftUI/List) with a [`ForEach`](/documentation/SwiftUI/ForEach) that’s
configured with the [`onDelete(perform:)`](/documentation/SwiftUI/DynamicViewContent/onDelete(perform:)) or
[`onMove(perform:)`](/documentation/SwiftUI/DynamicViewContent/onMove(perform:)) modifier provides controls to
delete or move list items while in edit mode. On devices without an
attached keyboard and mouse or trackpad, people can make multiple
selections in lists only when edit mode is active.

You can also customize your own views to react to edit mode.
The following example replaces a read-only [`Text`](/documentation/SwiftUI/Text) view with
an editable [`TextField`](/documentation/SwiftUI/TextField), checking for edit mode by
testing the wrapped value’s [`isEditing`](/documentation/SwiftUI/EditMode/isEditing) property:

```
@Environment(\.editMode) private var editMode
@State private var name = "Maria Ruiz"

var body: some View {
    Form {
        if editMode?.wrappedValue.isEditing == true {
            TextField("Name", text: $name)
        } else {
            Text(name)
        }
    }
    .animation(nil, value: editMode?.wrappedValue)
    .toolbar { // Assumes embedding this view in a NavigationView.
        EditButton()
    }
}
```

You can set the edit mode through the binding, or you can
rely on an [`EditButton`](/documentation/SwiftUI/EditButton) to do that for you, as the example above
demonstrates. The button activates edit mode when the user
taps the Edit button, and disables editing mode when the user taps Done.

---

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)