<!--
{
  "availability" : [
    "iOS: 18.4.0 -",
    "iPadOS: 18.4.0 -",
    "macCatalyst: 18.4.0 -",
    "macOS: 15.4.0 -",
    "visionOS: 2.4.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/WKWebExtensionTab/setPinned(_:for:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "c:objc(pl)WKWebExtensionTab(im)setPinned:forWebExtensionContext:completionHandler:"
  },
  "title" : "setPinned(_:for:completionHandler:)"
}
-->

# setPinned(_:for:completionHandler:)

Called to set the pinned state of the tab.

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

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

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

[`isPinned(for:)`](/documentation/WebKit/WKWebExtensionTab/isPinned(for:))

Called when the pinned state of the tab is needed.



---

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)