<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: -",
    "tvOS: 15.0.0 -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIButton/init(configuration:primaryAction:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "s:So8UIButtonC5UIKitE13configuration13primaryActionA2bCE13ConfigurationV_So8UIActionCSgtcfc"
  },
  "title" : "init(configuration:primaryAction:)"
}
-->

# init(configuration:primaryAction:)

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

```
@MainActor @preconcurrency convenience init(configuration: UIButton.Configuration, primaryAction: UIAction? = nil)
```

## Parameters

`configuration`

The button configuration.

`primaryAction`

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

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