Generic Instance Method


Sets the style for toggles within this view.


func toggleStyle<S>(_ style: S) -> some View where S : ToggleStyle



The style to set.


To set a specific style for all toggle instances within a view, use the toggleStyle(_:) modifier, as seen below:

VStack {
    Toggle("Vibrate on Ring", isOn: $vibrateOnRing)
    Toggle("Vibrate on Silent", isOn: $vibrateOnSilent)

See Also

Styling a Toggle

protocol ToggleStyle

A type that specifies the appearance and interaction of all toggles within a view hierarchy.

struct DefaultToggleStyle

The default toggle style.

struct SwitchToggleStyle

A toggle style that displays a leading label and a trailing switch.

struct CheckboxToggleStyle

A toggle style that displays a checkbox followed by its label.