---
title: "buttonWithConfiguration:primaryAction:"
framework: uikit
role: symbol
role_heading: Type Method
path: "uikit/uibutton/buttonwithconfiguration:primaryaction:"
---

# buttonWithConfiguration:primaryAction:

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

## Declaration

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

## Parameters

- `configuration`: The button configuration.
- `primaryAction`: The action to perform for the doc://com.apple.uikit/documentation/UIKit/UIControl/Event/primaryActionTriggered control event.

## Return Value

Return Value A new button.

## Discussion

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

## See Also

### Creating buttons from a configuration object

- [UIButtonConfiguration](uikit/uibuttonconfiguration.md)
