---
title: "init(title:message:primaryButton:secondaryButton:)"
framework: swiftui
role: symbol
role_heading: Initializer
path: "swiftui/alert/init(title:message:primarybutton:secondarybutton:)"
---

# init(title:message:primaryButton:secondaryButton:)

Creates an alert with two buttons.

## Declaration

```swift
init(title: Text, message: Text? = nil, primaryButton: Alert.Button, secondaryButton: Alert.Button)
```

## Parameters

- `title`: The title of the alert.
- `message`: The message to display in the body of the alert.
- `primaryButton`: The first button to show in the alert.
- `secondaryButton`: The second button to show in the alert.

## Discussion

Discussion The system determines the visual ordering of the buttons.

## See Also

### Creating an alert

- [init(title:message:dismissButton:)](swiftui/alert/init(title:message:dismissbutton:).md)
- [sideBySideButtons(title:message:primaryButton:secondaryButton:)](swiftui/alert/sidebysidebuttons(title:message:primarybutton:secondarybutton:).md)
