<!--
{
  "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/WKWebExtension/icon(for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "c:objc(cs)WKWebExtension(im)iconForSize:"
  },
  "title" : "icon(for:)"
}
-->

# icon(for:)

Returns the extension’s icon image for the specified size.

```
func icon(for size: CGSize) -> NSImage?
```

## Parameters

`size`

The size to use when looking up the icon.

## Return Value

The extension’s icon image, or `nil` if the icon was unable to be loaded.

## Discussion

This icon should represent the extension in settings or other areas that show the extension. The returned image will be the best match for the specified size that is available in the extension’s icon set. If no matching icon can be found, the method will return `nil`.

## See Also

[`actionIcon(for:)`](/documentation/WebKit/WKWebExtension/actionIcon(for:))

Returns the default action icon for the specified size.



---

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)