---
title: "init(type:primaryAction:)"
framework: uikit
role: symbol
role_heading: Initializer
path: "uikit/uibutton/init(type:primaryaction:)"
---

# init(type:primaryAction:)

Creates a new button with the specified type, registers the primary action event, and sets the title and image to the action’s title and image.

## Declaration

```swift
@MainActor @preconcurrency convenience init(type buttonType: UIButton.ButtonType = .system, primaryAction: UIAction?)
```

## Parameters

- `buttonType`: The type of button.
- `primaryAction`: The action to perform when the button is selected. The button registers this action for the doc://com.apple.uikit/documentation/UIKit/UIControl/Event/primaryActionTriggered control event and sets the title and image properties to the action’s title and image.

## See Also

### Creating buttons of a specific type

- [init(type:)](uikit/uibutton/init(type:).md)
- [UIButton.ButtonType](uikit/uibutton/buttontype-swift.enum.md)
