<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/Button/init(_:role:intent:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI",
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI6ButtonV012_AppIntents_aB0AA4TextVRszrlE_4role6intentACyAFGqd___AA0C4RoleVSgqd_0_tcSyRd__0dE00D6IntentRd_0_r0_lufc::OverloadGroup"
  },
  "title" : "init(_:role:intent:)"
}
-->

# init(_:role:intent:)

Creates a button with a specified role that performs an `AppIntent` and
generates its label from a string.

```
nonisolated init(_ title: some StringProtocol, role: ButtonRole?, intent: some AppIntent)
```

## Parameters

`title`

A string that describes the purpose of the button’s `intent`.

`role`

An optional semantic role describing the button. A value of
`nil` means that the button doesn’t have an assigned role.

`intent`

The `AppIntent` to execute.

## Discussion

This initializer creates a [`Text`](/documentation/SwiftUI/Text) view on your behalf, and treats the
title similar to [`init(_:)`](/documentation/SwiftUI/Text/init(_:)-9d1g4). See [`Text`](/documentation/SwiftUI/Text) for more
information about localizing strings.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)