isMixed
Whether the Toggle is currently in a mixed state.
Declaration
var isMixed: BoolDiscussion
Use this property to determine whether the toggle style should render a mixed state presentation. A mixed state corresponds to an underlying collection with a mix of true and false Bindings. To toggle the state, use the Bool.toggle() method on the isOn binding.
In the following example, a custom style uses the isMixed property to render the correct toggle state using symbols:
struct SymbolToggleStyle: ToggleStyle {
func makeBody(configuration: Configuration) -> some View {
Button {
configuration.isOn.toggle()
} label: {
Image(
systemName: configuration.isMixed
? "minus.circle.fill" : configuration.isOn
? "checkmark.circle.fill" : "circle.fill")
configuration.label
}
}
}