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.

Toggle

ButtonToggleStyle

A toggle style that displays as a button with its label as the title.

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

@State var isOn = false

var body: some View {
    List {
        Toggle("Foo1", isOn: $isOn)
        Toggle("Foo2", image: .cats24X24, isOn: $isOn)
        Toggle("Foo3", systemImage: "star", isOn: $isOn)
        Toggle(isOn: $isOn) {
            Label("Foo4", systemImage: "star")
            Text("Bar")
        }
        Toggle("Foo5", isOn: .constant(true))
    }
    .toggleStyle(.button)
}
iOS 15.0+ iPadOS 15.0+ macOS 12.0+ watchOS 9.0+ visionOS 1.0+

Every available iPhone screenshot for ButtonToggleStyle.

1 views