One Logo Pool Ball
SwiftUI · IOS API REFERENCE

ButtonStyleConfiguration

struct · iOS 13.0+ · SDK 27.1

struct ButtonStyleConfiguration

The properties of a button.

Members (3)

get · iOS 15.0+

role

TypeScript
get role(): (ButtonRole) | null
Swift declaration
let role: ButtonRole?

An optional semantic role that describes the button's purpose. A value of `nil` means that the Button doesn't have an assigned role. If the button does have a role, use it to make adjustments to the button's appearance. The following example shows a custom style that uses bold text when the role is ``ButtonRole/cancel``, ``ShapeStyle/red`` text when the role is ``ButtonRole/destructive``, and adds no special styling otherwise: struct MyButtonStyle: ButtonStyle { func makeBody(configuration: Configuration) -> some View { configuration.label .font( configuration.role == .cancel ? .title2.bold() : .title2) .foregroundColor( configuration.role == .destructive ? Color.red : nil) } } You can create one of each button using this style to see the effect: VStack(spacing: 20) { Button("Cancel", role: .cancel) {} Button("Delete", role: .destructive) {} Button("Continue") {} } .buttonStyle(MyButtonStyle()) ![A screenshot of three buttons stacked vertically. The first says Cancel in black, bold letters. The second says Delete in red, regular weight letters. The third says Continue in black, regular weight letters.](ButtonStyleConfiguration-role-1)

get · iOS 13.0+

label

TypeScript
get label(): ButtonStyleConfiguration_Label
Swift declaration
let label: ButtonStyleConfiguration.Label

A view that describes the effect of pressing the button.

get · iOS 13.0+

isPressed

TypeScript
get isPressed(): boolean
Swift declaration
let isPressed: Bool

A Boolean that indicates whether the user is currently pressing the button.

Skipped declarations

No declarations were skipped in this snapshot.

All SwiftUI types →