<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/buttonStyle(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE11buttonStyleyQrqd__AA06ButtonE0Rd__lF::OverloadGroup"
  },
  "title" : "buttonStyle(_:)"
}
-->

# buttonStyle(_:)

Sets the style for buttons within this view to a button style with a
custom appearance and standard interaction behavior.

```
nonisolated func buttonStyle<S>(_ style: S) -> some View where S : ButtonStyle
```

## Discussion

Use this modifier to set a specific style for all button instances
within a view:

```
HStack {
    Button("Sign In", action: signIn)
    Button("Register", action: register)
}
.buttonStyle(.bordered)
```

You can also use this modifier to set the style for controls that
acquire a button style through composition, like the [`Menu`](/documentation/SwiftUI/Menu) and
[`Toggle`](/documentation/SwiftUI/Toggle) views in the following example:

```
VStack {
    Menu("Terms and Conditions") {
        Button("Open in Preview", action: openInPreview)
        Button("Save as PDF", action: saveAsPDF)
    }
    Toggle("Remember Password", isOn: $isToggleOn)
    Toggle("Flag", isOn: $flagged)
    Button("Sign In", action: signIn)
}
.menuStyle(.button)
.toggleStyle(.button)
.buttonStyle(.bordered)
```

The [`menuStyle(_:)`](/documentation/SwiftUI/View/menuStyle(_:)) modifier causes the Terms
and Conditions menu to render as a button. Similarly, the
[`toggleStyle(_:)`](/documentation/SwiftUI/View/toggleStyle(_:)) modifier causes the two toggles to
render as buttons. The button style modifier then causes not only
the explicit Sign In [`Button`](/documentation/SwiftUI/Button), but also the menu and toggles with
button styling, to render with the bordered button style.

---

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)