---
title: "init(role:action:label:)"
framework: swiftui
role: symbol
role_heading: Initializer
path: "swiftui/button/init(role:action:label:)"
---

# init(role:action:label:)

Creates a button with a specified role that displays a custom label.

## Declaration

```swift
@preconcurrency nonisolated init(role: ButtonRole?, action: @escaping @MainActor () -> Void, @ContentBuilder label: () -> Label)
```

## Parameters

- `role`: An optional semantic role that describes the button. A value of nil means that the button doesn’t have an assigned role.
- `action`: The action to perform when the user interacts with the button.
- `label`: A view that describes the purpose of the button’s action.

## See Also

### Creating a button with a role

- [init(_:role:action:)](swiftui/button/init(_:role:action:).md)
- [init(_:image:role:action:)](swiftui/button/init(_:image:role:action:).md)
- [init(_:systemImage:role:action:)](swiftui/button/init(_:systemimage:role:action:).md)
