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

# setPinned(_:for:completionHandler:)

Called to set the pinned state of the tab.

## Declaration

```swift
optional func setPinned(_ pinned: Bool, for context: WKWebExtensionContext, completionHandler: @escaping ((any Error)?) -> Void)
```

```swift
optional func setPinned(_ pinned: Bool, for context: WKWebExtensionContext) async throws
```

## Parameters

- `pinned`: A boolean value indicating whether to pin the tab.
- `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 This is equivalent to the user selecting to pin or unpin the tab through a menu item. When a tab is pinned, it should be moved to the front of the tab bar and usually reduced in size. When a tab is unpinned, it should be restored to a normal size and position in the tab bar. No action is performed if not implemented.

## See Also

### Related Documentation

- [isPinned(for:)](webkit/wkwebextensiontab/ispinned(for:).md)
