iPhone SwiftUI layouts

Explore SwiftUI APIs, components, and modifiers with interactive iPhone previews, Swift code, and Apple documentation. Compare every available orientation, appearance, and design.

Button

Button Roles

A value that describes the purpose of a button.

Explore Button Roles on iPhone in portrait, with SwiftUI code and Apple API documentation.

VStack {
    HStack {
        Button("Tap Me", role: .cancel, action: action)
            .buttonStyle(.plain)
        Button("Tap Me", role: .cancel, action: action)
            .buttonStyle(.borderless)
        Button("Tap Me", role: .cancel, action: action)
            .buttonStyle(.bordered)
        Button("Tap Me", role: .cancel, action: action)
            .buttonStyle(.borderedProminent)
    }
    HStack {
        Button("Tap Me", role: .destructive, action: action)
            .buttonStyle(.plain)
        Button("Tap Me", role: .destructive, action: action)
            .buttonStyle(.borderless)
        Button("Tap Me", role: .destructive, action: action)
            .buttonStyle(.bordered)
        Button("Tap Me", role: .destructive, action: action)
            .buttonStyle(.borderedProminent)
    }
}
iOS 15.0+ iPadOS 15.0+ macOS 12.0+ watchOS 8.0+ tvOS 15.0+ visionOS 1.0+

Every available iPhone screenshot for Button Roles.

2 views