Contents

PrimitiveButtonStyle

A type that applies custom interaction behavior and a custom appearance to all buttons within a view hierarchy.

Declaration

@MainActor @preconcurrency protocol PrimitiveButtonStyle

Overview

To configure the current button style for a view hierarchy, use the buttonStyle(_:) modifier. Specify a style that conforms to PrimitiveButtonStyle to create a button with custom interaction behavior. To create a button with the standard button interaction behavior defined for each platform, use ButtonStyle instead.

A type conforming to this protocol inherits @preconcurrency @MainActor isolation from the protocol if the conformance is included in the type’s base declaration:

struct MyCustomType: Transition {
    // `@preconcurrency @MainActor` isolation by default
}

Isolation to the main actor is the default, but it’s not required. Declare the conformance in an extension to opt out of main actor isolation:

extension MyCustomType: Transition {
    // `nonisolated` by default
}

Topics

Getting built-in button styles

Creating custom button styles

Supporting types

See Also

Styling buttons