# SwiftUI forms: Toggle

> Learn how to use the Toggle control in SwiftUI to get an on or off choice from the user, binding a Bool value to its isOn parameter like the Settings app.

Author: Flavio Copes | Published: 2021-09-26 | Canonical: https://flaviocopes.com/swiftui-forms-toggle/

Another common form control is `Toggle`. 

You can see it widely used in the Settings app.

```swift
struct ContentView: View {
    @State private var enabled = true
    
    var body: some View {
        Form {
            Toggle("Enable?", isOn: $enabled)
        }
    }
}
```

![Xcode showing SwiftUI Toggle code with iPhone simulator displaying a green enabled toggle control](https://flaviocopes.com/images/swiftui-forms-toggle/Screen_Shot_2021-09-23_at_16.58.43.png)

It works similarly to a `TextField` view, except instead of a `String` value passed with the `text` parameter, we pass a `Bool` value to `isOn`.

If you set it to `true` the toggle is enabled, if you set it to `false` it's disabled:

![Xcode showing SwiftUI Toggle code with iPhone simulator displaying a gray disabled toggle control](https://flaviocopes.com/images/swiftui-forms-toggle/Screen_Shot_2021-09-23_at_17.00.37.png)

Of course the user can enable or disable it by tapping on the control, and that automatically updates the variable passed to `isOn`.
