MasterOnce
HomeBlogHow-To
3 min readMar 11, 2026
Swift

How to Use @Binding

Pass state down and edits back up.

Steps

  1. Paste the view into a SwiftUI file.
  2. Set it as a preview or root view.
  3. Update state or bindings to match your data.

Copy and paste

import SwiftUI

struct ToggleRow: View {
    @Binding var isOn: Bool

    var body: some View {
        Toggle("Enabled", isOn: $isOn)
    }
}

struct SettingsView: View {
    @State private var enabled = false

    var body: some View {
        ToggleRow(isOn: $enabled)
    }
}

Notes

  • Use @State for local values and bindings for child views.
  • Extract subviews when the body grows.