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.
215elements
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.
SwiftUI code
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 ? "😾" : "😻")")
}
}
}Compatibility
iOS 16.0+ iPadOS 16.0+ macOS 13.0+ watchOS 9.0+ tvOS 16.0+ visionOS 1.0+
Tags
Found an issue or have a suggestion?
All variants
Every available iPhone screenshot for Multiple Sources Toggle.