Switch

Represents a Material UI styled switch for toggling boolean states.

Overview

The Switch view is used to toggle a boolean state on or off with a Material UI style switch. It allows users to toggle between checked and unchecked states.

To use the Switch, initialize it with a title key and a binding to the boolean state.

Initializer

Creates a switch with a specified title and state binding.

Switch(_ titleKey: String, isOn: Binding<Bool>)

Parameters

Parameter

Description

titleKey

The title key of the switch.

isOn

A binding to a boolean value that determines the on/off state of the switch.

Example

@State private var isSwitchOn = false

var body: some View {
    Container {
        Switch("Toggle Switch", isOn: $isTurnedOn)
    }
}

Last updated