swiftui · note · architecture · state

Callback Closures vs Bindings in SwiftUI

Published February 24, 2026 · 1 min read · beginner

Context

Both @Binding and callbacks let child views change behavior, but they represent different ownership boundaries.


The snippet

struct SearchField: View {
    @Binding var query: String
    let onSubmit: () -> Void

    var body: some View {
        TextField("Search", text: $query)
            .onSubmit(onSubmit)
    }
}

Why this works

Use a binding when the child edits parent-owned state directly. Use a closure when the child emits intent and the parent decides what happens.


Use it when…

  • the child needs read/write access to a specific value (@Binding)
  • you want explicit intent for side effects (onSubmit, onDelete)
  • you want APIs that show ownership clearly

Avoid it when…

  • you pass many bindings where one intent callback is enough
  • callbacks start mutating unrelated state branches
  • ownership is unclear in the child interface

Takeaway: Bindings edit data, callbacks express intent.

Next steps