---
title: "renameAction(_:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/view/renameaction(_:)"
---

# renameAction(_:)

Sets a closure to run for the rename action.

## Declaration

```swift
nonisolated func renameAction(_ action: @escaping () -> Void) -> some View

```

## Parameters

- `action`: A closure to run when renaming.

## Return Value

Return Value A view that has the specified rename action.

## Discussion

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 = true } } When the user taps the rename button in the context menu, the rename action focuses the text field by setting the isFocused property to true.

## See Also

### Renaming a document

- [RenameButton](swiftui/renamebutton.md)
- [rename](swiftui/environmentvalues/rename.md)
- [RenameAction](swiftui/renameaction.md)
