<!--
{
  "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/View/renameAction(_:)-324yw",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE12renameActionyQrAA10FocusStateV7BindingVySb_GF"
  },
  "title" : "renameAction(_:)"
}
-->

# renameAction(_:)

Sets the rename action in the environment to update focus state.

```
nonisolated func renameAction(_ isFocused: FocusState<Bool>.Binding) -> some View
```

## Parameters

`isFocused`

The focus binding to update when
activating the rename action.

## Return Value

A view that has the specified rename action.

## Discussion

Use this modifier in conjunction with the `RenameButton` to implement
standard rename interactions. A rename button receives its action
from the environment. Use this modifier to customize the action
provided to the rename button.

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

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

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

---

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)