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

Multiple Sources Toggle

Creates a toggle that updates the selected property for all sources. Once toggled, all sources will have the same value.

Explore Multiple Sources Toggle on iPhone in portrait, with SwiftUI code and Apple API documentation.

struct Cat: Identifiable {
    let id = UUID()
    var name: String
    var isHungry: Bool
}

@State private var sources = [
    Cat(name: "Bella", isHungry: false),
    Cat(name: "Max", isHungry: true)
]

var body: some View {
    List {
        Toggle("Foo1", sources: $sources, isOn: \.isHungry)
        ForEach(sources) { pet in
            Text("\(pet.name): \(pet.isHungry ? "😾" : "😻")")
        }
    }
}
iOS 16.0+ iPadOS 16.0+ macOS 13.0+ watchOS 9.0+ tvOS 16.0+ visionOS 1.0+

Every available iPhone screenshot for Multiple Sources Toggle.

1 views