<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/RenameButton",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI12RenameButtonV"
  },
  "title" : "RenameButton"
}
-->

# RenameButton

A button that triggers a standard rename action.

```
nonisolated struct RenameButton<Label> where Label : View
```

## Overview

A rename button receives its action from the environment. Use the
[`renameAction(_:)`](/documentation/SwiftUI/View/renameAction(_:)) modifier to set the action. The
system disables the button if you don’t define an action.

```
struct RowView: View {
    @State private var text = ""
    @FocusState private var isFocused: Bool

    var body: some View {
        TextField(text: $text) {
            Text("Prompt")
        }
        .focused($isFocused)
        .contextMenu {
            RenameButton()
            // ... your own custom actions
        }
        .renameAction { isFocused = true }
    }
}
```

When someone taps the rename button in the context menu, the rename
action focuses the text field by setting the `isFocused`
property to true.

You can use this button inside of a navigation title menu and the
navigation title modifier automatically configures the environment
with the appropriate rename action.

```
ContentView()
    .navigationTitle($contentTitle)
    .toolbarTitleMenu {
        // ... your own custom actions
        RenameButton()
    }
```

## Topics

### Creating an rename button

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

Creates a rename button.

## 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)