0Pricing
SwiftUI Academy · Lesson

On/Off with Toggle

Bind a Toggle to a boolean setting.

Meet the Toggle

A Toggle is SwiftUI's on/off switch. It is perfect for settings like notifications, dark mode, or any yes-or-no choice. 🔘

Toggle Needs a Boolean

Every Toggle reflects a Bool value. When the switch is on the value is true; when it is off the value is false. They stay in sync.

All lessons in this course

  1. On/Off with Toggle
  2. Choosing Values with Slider
  3. Incrementing with Stepper
  4. Selecting Options with Picker
← Back to SwiftUI Academy