---
title: "EditButton | Explore SwiftUI"
description: "A button that toggles the edit mode environment value. Learn how to use EditButton in SwiftUI with visual code examples."
canonical_url: "https://exploreswiftui.com/library/button/editbutton"
meta:
  author: "Explore SwiftUI"
  "og:description": "A button that toggles the edit mode environment value. Learn how to use EditButton in SwiftUI with visual code examples."
  "og:image": "https://exploreswiftui.com/_og/d/c_Component%2Ctitle_EditButton%2Cdescription_A%2Bbutton%2Bthat%2Btoggles%2Bthe%2Bedit%2Bmode%2Benvironment%2Bvalue%2Ccategory_Button%2Cimage_~L2FwaS9pbWFnZXMvMzYvdmFyaWFudHMvMjM5P3Y9MTc5MDA3MzQ3ODg0MiZyPTImdz0xMjgwJnE9ODUmZj1qcGVn%2CimageMode_crop%2CimagePosition_center%2CimageFrame_~cG9zaXRpb246IGFic29sdXRlOyByaWdodDogMDsgd2lkdGg6IDY0MHB4OyBoZWlnaHQ6IDQ4MHB4OyBkaXNwbGF5OiBmbGV4OyBvdmVyZmxvdzogaGlkZGVuOyBiYWNrZ3JvdW5kOiAjRkZGRkZGOyBib3gtc2hhZG93OiAwIC0xMHB4IDUwcHggcmdiYSgzNyw5OSwyMzUsMC4xOCk7IGJvcmRlci1sZWZ0OiAxcHggc29saWQgcmdiYSgwLDAsMCwwLjA2KTsgdG9wOiA3NXB4OyBib3JkZXItdG9wOiAxcHggc29saWQgcmdiYSgwLDAsMCwwLjA2KTsgYm9yZGVyLWJvdHRvbTogMXB4IHNvbGlkIHJnYmEoMCwwLDAsMC4wNik7IGJvcmRlci10b3AtbGVmdC1yYWRpdXM6IDMycHg7IGJvcmRlci1ib3R0b20tbGVmdC1yYWRpdXM6IDMycHg7%2Cprops_eyJwbGF0Zm9ybXMiOlsiaU9TIiwiaVBhZE9TIiwidmlzaW9uT1MiXX0%2Cp_Ii9saWJyYXJ5L2J1dHRvbi9lZGl0YnV0dG9uIg%2Cs_A1BniSpqdFtNDV-b.png"
  "og:image:height": "630"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "EditButton | Explore SwiftUI"
  "twitter:description": "A button that toggles the edit mode environment value. Learn how to use EditButton in SwiftUI with visual code examples."
  "twitter:image": "https://exploreswiftui.com/_og/d/c_Component%2Ctitle_EditButton%2Cdescription_A%2Bbutton%2Bthat%2Btoggles%2Bthe%2Bedit%2Bmode%2Benvironment%2Bvalue%2Ccategory_Button%2Cimage_~L2FwaS9pbWFnZXMvMzYvdmFyaWFudHMvMjM5P3Y9MTc5MDA3MzQ3ODg0MiZyPTImdz0xMjgwJnE9ODUmZj1qcGVn%2CimageMode_crop%2CimagePosition_center%2CimageFrame_~cG9zaXRpb246IGFic29sdXRlOyByaWdodDogMDsgd2lkdGg6IDY0MHB4OyBoZWlnaHQ6IDQ4MHB4OyBkaXNwbGF5OiBmbGV4OyBvdmVyZmxvdzogaGlkZGVuOyBiYWNrZ3JvdW5kOiAjRkZGRkZGOyBib3gtc2hhZG93OiAwIC0xMHB4IDUwcHggcmdiYSgzNyw5OSwyMzUsMC4xOCk7IGJvcmRlci1sZWZ0OiAxcHggc29saWQgcmdiYSgwLDAsMCwwLjA2KTsgdG9wOiA3NXB4OyBib3JkZXItdG9wOiAxcHggc29saWQgcmdiYSgwLDAsMCwwLjA2KTsgYm9yZGVyLWJvdHRvbTogMXB4IHNvbGlkIHJnYmEoMCwwLDAsMC4wNik7IGJvcmRlci10b3AtbGVmdC1yYWRpdXM6IDMycHg7IGJvcmRlci1ib3R0b20tbGVmdC1yYWRpdXM6IDMycHg7%2Cprops_eyJwbGF0Zm9ybXMiOlsiaU9TIiwiaVBhZE9TIiwidmlzaW9uT1MiXX0%2Cp_Ii9saWJyYXJ5L2J1dHRvbi9lZGl0YnV0dG9uIg%2Cs_A1BniSpqdFtNDV-b.png"
  "twitter:title": "EditButton | Explore SwiftUI"
---

> Index of every page on this site: [llms.txt](https://exploreswiftui.com/llms.txt)

**Interactive previews**[ iPhone](https://exploreswiftui.com/iphone?element=36)

# **EditButton**

A button that toggles the edit mode environment value

![EditButton - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/36/variants/239?v=1790073478842&r=2&w=800&q=80&f=webp)

### **Platform Compatibility**

iOS 13.0+ iPadOS 13.0+ visionOS 1.0+

### **Tags**

### **SwiftUI Code**

[ Docs](https://developer.apple.com/documentation/swiftui/editbutton)

```
@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

![Connect Wizard](https://exploreswiftui.com/_ipx/f_webp&q_80&s_48x48/images/connect-wizard-icon.png)

**Connect Wizard**

**Unlock insights App Store Connect doesn’t show you.**

[** Get Started **](https://apps.apple.com/app/apple-store/id6747314580?pt=121213751&ct=Explore%20SwiftUI%20Banner&mt=8)

### **More Button Components **

[**View all **](https://exploreswiftui.com/library/button)

![Button Sizing - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/190/variants/3?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Button Sizing**

The preferred sizing behavior of buttons in the view hierarchy.

![Role Button With Default Label - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/134/variants/424?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Role Button With Default Label**

Creates a button that displays a default label.

![Glass Button Styles - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/87/variants/314?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Glass Button Styles**

A button style that applies glass border artwork based on the button’s context

![RenameButton - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/37/variants/213?v=1790073478842&r=2&w=412&q=75&f=webp)

### **RenameButton**

A button that triggers a standard rename action

![PasteButton - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/35/variants/235?v=1790073478842&r=2&w=412&q=75&f=webp)

### **PasteButton**

A system button that reads items from the pasteboard and delivers it to a closure.

![Button Tint - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/34/variants/408?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Button Tint**

Sets the buttons tint color

![Button Roles - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/33/variants/718?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Button Roles**

A value that describes the purpose of a button.

![Button Border Shape - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/32/variants/179?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Button Border Shape**

A shape used to draw a button’s border.

### **Explore Other Components **

[**Browse all **](https://exploreswiftui.com/)

![RadioGroupPickerStyle - macOS - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/183/variants/564?v=1790073478842&r=2&w=412&q=75&f=webp)

### **RadioGroupPickerStyle**

A picker style that presents the options as a group of radio buttons.

![Default Min List Row Height - iOS on iPhone - Portrait - Flat Design - Light Mode - Preview](https://exploreswiftui.com/api/images/110/variants/312?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Default Min List Row Height**

The default minimum height of rows in a list.

![Menu - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/17/variants/122?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Menu**

A control for presenting a menu of actions.

![Nested Menu - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/21/variants/151?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Nested Menu**

A Menu inside a Menu

![TextFieldLink - iOS on iPhone - Portrait - Flat Design - Light Mode - Preview](https://exploreswiftui.com/api/images/76/variants/192?v=1790073478842&r=2&w=412&q=75&f=webp)

### **TextFieldLink**

A control that requests text input from the user when pressed

![NavigationLinkPickerStyle - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/181/variants/560?v=1790073478842&r=2&w=412&q=75&f=webp)

### **NavigationLinkPickerStyle**

A picker style represented by a navigation link that presents the options by pushing a List-style picker view.

![Stepped Min Max Label Slider - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/51/variants/396?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Stepped Min Max Label Slider**

Creates a slider to select a value from a given range, subject to a step increment, which displays the provided labels

![Only Horizontal Split Arrangement Style - iOS on iPhone Duo - Portrait - Fully Open - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/245/variants/1614?v=1791207712827&r=2&w=412&q=75&f=webp)

### **Only Horizontal Split Arrangement Style**

Creates a horizontal split arrangement only in portrait orientation. In landscape orientation, no split is applied.

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://exploreswiftui.com/#website","@type":"WebSite","description":"A visual library for SwiftUI APIs, components, and modifiers","inLanguage":"en-US","name":"Explore SwiftUI","url":"https://exploreswiftui.com/","publisher":{"@id":"https://exploreswiftui.com/#identity"}},{"@id":"https://exploreswiftui.com/library/button/editbutton#webpage","@type":"WebPage","dateModified":"2025-12-27T17:40:57.858Z","datePublished":"2025-06-03T14:28:16.568Z","description":"A button that toggles the edit mode environment value. Learn how to use EditButton in SwiftUI with visual code examples.","name":"EditButton","url":"https://exploreswiftui.com/library/button/editbutton","breadcrumb":{"@id":"https://exploreswiftui.com/library/button/editbutton#breadcrumb"},"isPartOf":{"@id":"https://exploreswiftui.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://exploreswiftui.com/library/button/editbutton"]}],"primaryImageOfPage":{"@id":"https://exploreswiftui.com/#logo"}},{"@id":"https://exploreswiftui.com/#identity","@type":"Organization","description":"A visual library for SwiftUI APIs, components, and modifiers","name":"Explore SwiftUI","url":"https://exploreswiftui.com","logo":{"@id":"https://exploreswiftui.com/#logo"},"sameAs":["https://x.com/Typ0genius","https://mastodon.social/@Typ0genius"]},{"@id":"https://exploreswiftui.com/library/button/editbutton#article","dateModified":"2025-12-27T17:40:57.858Z","datePublished":"2025-06-03T14:28:16.568Z","description":"A button that toggles the edit mode environment value. Learn how to use EditButton in SwiftUI with visual code examples.","headline":"EditButton","inLanguage":"en-US","name":"EditButton","thumbnailUrl":"https://exploreswiftui.com/api/images/36/variants/239?v=1790073478842&r=2","url":"https://exploreswiftui.com/library/button/editbutton","@type":["Article","TechArticle"],"about":{"@type":"Thing","name":"SwiftUI"},"author":{"@id":"https://exploreswiftui.com/#identity"},"image":{"@id":"https://exploreswiftui.com/#/schema/image/1"},"isPartOf":{"@type":"WebSite","name":"Explore SwiftUI","url":"https://exploreswiftui.com"},"mainEntityOfPage":{"@id":"https://exploreswiftui.com/library/button/editbutton#webpage"},"publisher":{"@id":"https://exploreswiftui.com/#identity"}},{"@id":"https://exploreswiftui.com/library/button/editbutton#/schema/software-source-code/1","@type":"SoftwareSourceCode","codeRepository":"https://developer.apple.com/documentation/swiftui/editbutton","codeSampleType":"full example","description":"A button that toggles the edit mode environment value. Learn how to use EditButton in SwiftUI with visual code examples.","name":"EditButton SwiftUI Example","programmingLanguage":"Swift","runtimePlatform":"SwiftUI","text":"@Environment(\\.editMode) private var editMode\n@State private var name = \"Foo\"\n\nvar body: some View {\n    HStack {\n        if editMode?.wrappedValue.isEditing == true {\n            TextField(\"Name\", text: $name)\n        } else {\n            Text(name)\n        }\n        EditButton()\n    }\n}","about":[{"@type":"Thing","name":"SwiftUI"},{"@type":"Thing","name":"Button"},{"@type":"Thing","name":"EditButton"}]},{"@id":"https://exploreswiftui.com/library/button/editbutton#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Home","item":"https://exploreswiftui.com","position":1},{"@type":"ListItem","name":"Button","item":"https://exploreswiftui.com/library/button","position":2},{"@type":"ListItem","name":"EditButton","item":"https://exploreswiftui.com/library/button/editbutton","position":3}]},{"@id":"https://exploreswiftui.com/#logo","@type":"ImageObject","caption":"Explore SwiftUI","contentUrl":"https://exploreswiftui.com/apple-touch-icon.png","inLanguage":"en","url":"https://exploreswiftui.com/apple-touch-icon.png"},{"@id":"https://exploreswiftui.com/#/schema/image/1","@type":"ImageObject","contentUrl":"https://exploreswiftui.com/api/images/36/variants/239?v=1790073478842&r=2","inLanguage":"en","url":"https://exploreswiftui.com/api/images/36/variants/239?v=1790073478842&r=2"}]}
```