Multiple Sources Toggle
Creates a toggle that updates the selected property for all sources. Once toggled, all sources will have the same value.
Platform Compatibility
iOS 16.0+ iPadOS 16.0+ macOS 13.0+ watchOS 9.0+ tvOS 16.0+ visionOS 1.0+
Tags
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 ? "😾" : "😻")")
}
}
}Found an issue or have a suggestion?
Created: July 5, 2026Updated: July 5, 2026