<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/EditButton",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI10EditButtonV"
  },
  "title" : "EditButton"
}
-->

# EditButton

A button that toggles the edit mode environment value.

```
nonisolated struct EditButton
```

## Overview

An edit button toggles the environment’s [`editMode`](/documentation/SwiftUI/EnvironmentValues/editMode)
value for content within a container that supports edit mode.
In the following example, an edit button placed inside a [`NavigationView`](/documentation/SwiftUI/NavigationView)
supports editing of a [`List`](/documentation/SwiftUI/List):

```
@State private var fruits = [
    "Apple",
    "Banana",
    "Papaya",
    "Mango"
]

var body: some View {
    NavigationView {
        List {
            ForEach(fruits, id: \.self) { fruit in
                Text(fruit)
            }
            .onDelete { fruits.remove(atOffsets: $0) }
            .onMove { fruits.move(fromOffsets: $0, toOffset: $1) }
        }
        .navigationTitle("Fruits")
        .toolbar {
            EditButton()
        }
    }
}
```

Because the [`ForEach`](/documentation/SwiftUI/ForEach) in the above example defines behaviors for
[`onDelete(perform:)`](/documentation/SwiftUI/DynamicViewContent/onDelete(perform:)) and
[`onMove(perform:)`](/documentation/SwiftUI/DynamicViewContent/onMove(perform:)), the editable list displays the
delete and move UI when the user taps Edit. Notice that the Edit button
displays the title “Done” while edit mode is active:

![A screenshot of an app with an Edit button in the navigation bar.](images/com.apple.SwiftUI/EditButton-1@2x.png)

You can also create custom views that react to changes in the edit mode
state, as described in [`EditMode`](/documentation/SwiftUI/EditMode).

## Topics

### Creating an edit button

[`init()`](/documentation/SwiftUI/EditButton/init())

Creates an Edit button instance.

## Relationships

### Conforms To

[`View`](/documentation/SwiftUI/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)