<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIButton/buttonWithConfiguration:primaryAction:",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIButton(cm)buttonWithConfiguration:primaryAction:"
  },
  "title" : "buttonWithConfiguration:primaryAction:"
}
-->

# buttonWithConfiguration:primaryAction:

Creates a new button with the specified configuration and registers the primary action event.

```
+ (instancetype) buttonWithConfiguration:(UIButtonConfiguration *) configuration primaryAction:(UIAction *) primaryAction;
```

## Parameters

`configuration`

The button configuration.

`primaryAction`

The action to perform for the [`primaryActionTriggered`](/documentation/UIKit/UIControl/Event/primaryActionTriggered) control event.

## Return Value

A new button.

## Discussion

If the primary action contains a title or an image, this method copies them to the configuration and the button displays them.

---

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)