<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSButton/setButtonType(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSButton(im)setButtonType:"
  },
  "title" : "setButtonType(_:)"
}
-->

# setButtonType(_:)

Sets the button’s type, which affects its user interface and behavior when clicked.

```
func setButtonType(_ type: NSButton.ButtonType)
```

## Parameters

`type`

A constant specifying the type of the button. The available button types are listed under [`NSButton.ButtonType`](/documentation/AppKit/NSButton/ButtonType) in the [`NSButtonCell`](/documentation/AppKit/NSButtonCell) class.

## Discussion

This method causes the button to update to reflect the new type before the method finishes executing.

The types available are for the most common button types, which are also accessible in Interface Builder. You can configure different behavior with the `NSButtonCell` methods  [`highlightsBy`](/documentation/AppKit/NSButtonCell/highlightsBy) and [`showsStateBy`](/documentation/AppKit/NSButtonCell/showsStateBy).

Note that there is no `-buttonType` method. The set method sets various button properties that together establish the behavior of the type.

## See Also

[`image`](/documentation/AppKit/NSButton/image)

The image that appears on the button when it’s in an off state, or `nil` if there is no such image.

[`setButtonType(_:)`](/documentation/AppKit/NSButtonCell/setButtonType(_:))

Sets how the button highlights while pressed and how it shows its state.

[`alternateImage`](/documentation/AppKit/NSButton/alternateImage)

An alternate image that appears on the button when the button is in an on state.



---

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)