<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSWindow/standardWindowButton(_:for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSWindow(cm)standardWindowButton:forStyleMask:"
  },
  "title" : "standardWindowButton(_:for:)"
}
-->

# standardWindowButton(_:for:)

Returns a new instance of a given standard window button, sized appropriately for a given window style.

```
class func standardWindowButton(_ b: NSWindow.ButtonType, for styleMask: NSWindow.StyleMask) -> NSButton?
```

## Parameters

`b`

The type of standard window button to return.

`styleMask`

The window style for which `b` is to be sized. See [`NSWindow.StyleMask`](/documentation/AppKit/NSWindow/StyleMask-swift.struct)  for the list of allowable values.

## Return Value

The new window button of the type identified by `b`; `nil` when no such button type exists.

## Discussion

The caller is responsible for adding the button to the view hierarchy and for setting the target to be the window.

---

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)