---
title: "buttonStyle(_:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/view/buttonstyle(_:)"
---

# buttonStyle(_:)

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

## Declaration

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

```

## Discussion

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 and 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(_:) modifier causes the Terms and Conditions menu to render as a button. Similarly, the toggleStyle(_:) modifier causes the two toggles to render as buttons. The button style modifier then causes not only the explicit Sign In Button, but also the menu and toggles with button styling, to render with the bordered button style.

## See Also

### Creating buttons

- [Button](swiftui/button.md)
- [buttonBorderShape(_:)](swiftui/view/buttonbordershape(_:).md)
- [ButtonBorderShape](swiftui/buttonbordershape.md)
- [buttonRepeatBehavior(_:)](swiftui/view/buttonrepeatbehavior(_:).md)
- [ButtonRepeatBehavior](swiftui/buttonrepeatbehavior.md)
- [buttonRepeatBehavior](swiftui/environmentvalues/buttonrepeatbehavior.md)
- [buttonSizing(_:)](swiftui/view/buttonsizing(_:).md)
- [ButtonSizing](swiftui/buttonsizing.md)
- [ButtonRole](swiftui/buttonrole.md)
