Generic Structure


A control that toggles between on and off states.


struct Toggle<Label> where Label : View


The appearance and interaction of Toggle is determined at runtime and can be customized. Toggle uses the ToggleStyle provided by its environment to define its appearance and interaction. Each platform provides a default style that reflects the platform style, but providing a new style will redefine all Toggle instances within that environment.


Creating a Toggle

init<S>(S, isOn: Binding<Bool>)
init(isOn: Binding<Bool>, label: () -> Label)

Creates an instance that displays state based on isOn.

Styling a Toggle

Applying Standard Modifiers

View Modifiers

Configure this view and the views it contains by applying standard modifiers.


Conforms To

See Also

Value Selectors

struct Picker

A control for selecting from a set of mutually exclusive values.

struct DatePicker

A control for selecting an absolute date.

struct Slider

A control for selecting a value from a bounded linear range of values.

struct Stepper

A control used to perform semantic increment and decrement actions.