init(role:action:label:)
Creates a button with a specified role that displays a custom label.
Declaration
@preconcurrency nonisolated init(role: ButtonRole?, action: @escaping @MainActor () -> Void, @ViewBuilder label: () -> Label)Parameters
- role:
An optional semantic role that describes the button. A value of
nilmeans 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.