Structure¶
DefaultButtonStyle¶
The default button style, based on the button's context.¶
Declaration¶
struct DefaultButtonStyle : PrimitiveButtonStyle
Overview¶
If you create a button directly on a blank canvas, the style varies by platform. iOS uses the borderless button style by default, whereas macOS, tvOS, and watchOS use the bordered button style.
struct ExampleView: View {
var body: some View {
VStack {
Button("PlainBanana🍌🍌") { tap() }
.buttonStyle(PlainButtonStyle())
Button("BorderlessBanana🍌🍌") { tap() }
.buttonStyle(BorderlessButtonStyle())
Button("DefaultBanana🍌🍌") { tap() }
.buttonStyle(DefaultButtonStyle())
}
.font(.title2)
}
func tap() { /\* implement here \*/ }
}

If you create a button inside a container, like a List, the style resolves to the recommended style for buttons inside that container for that specific platform.
You can override a button's style. To apply the default style to a button, or to a view that contains buttons, use the buttonStyle(_:) modifier.
Availability¶
iOS 13.0+
macOS 10.15+
tvOS 13.0+
watchOS 6.0+
Topics¶
Instance Method¶
makeBody(configuration:) Creates a view that represents the body of a button.
Initializer¶
init() Creates a default button style.
Type Alias¶
Body A view that represents the body of a button.