---
title: "setParentTab(_:for:completionHandler:)"
framework: webkit
role: symbol
role_heading: Instance Method
path: "webkit/wkwebextensiontab/setparenttab(_:for:completionhandler:)"
---

# setParentTab(_:for:completionHandler:)

Called to set or clear the parent tab for the tab.

## Declaration

```swift
optional func setParentTab(_ parentTab: (any WKWebExtensionTab)?, for context: WKWebExtensionContext, completionHandler: @escaping ((any Error)?) -> Void)
```

```swift
optional func setParentTab(_ parentTab: (any WKWebExtensionTab)?, for context: WKWebExtensionContext) async throws
```

## Parameters

- `parentTab`: The tab that should be set as the parent of the tab. If \c nil is provided, the current parent tab should be cleared.
- `context`: The context in which the web extension is running.
- `completionHandler`: A block that must be called upon completion. It takes a single error argument, which should be provided if any errors occurred.

## Discussion

Discussion No action is performed if not implemented.

## See Also

### Related Documentation

- [parentTab(for:)](webkit/wkwebextensiontab/parenttab(for:).md)
