<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/Binding",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI7BindingV"
  },
  "title" : "Binding"
}
-->

# Binding

A property wrapper type that can read and write a value owned by a source of
truth.

```
@frozen @propertyWrapper @dynamicMemberLookup struct Binding<Value>
```

## Overview

Use a binding to create a two-way connection between a property that stores
data, and a view that displays and changes the data. A binding connects a
property to a source of truth stored elsewhere, instead of storing data
directly. For example, a button that toggles between play and pause can
create a binding to a property of its parent view using the `Binding`
property wrapper.

```
struct PlayButton: View {
    @Binding var isPlaying: Bool

    var body: some View {
        Button(isPlaying ? "Pause" : "Play") {
            isPlaying.toggle()
        }
    }
}
```

The parent view declares a property to hold the playing state, using the
[`State`](/documentation/SwiftUI/State) property wrapper to indicate that this property is the value’s
source of truth.

```
struct PlayerView: View {
    var episode: Episode
    @State private var isPlaying: Bool = false

    var body: some View {
        VStack {
            Text(episode.title)
                .foregroundStyle(isPlaying ? .primary : .secondary)
            PlayButton(isPlaying: $isPlaying) // Pass a binding.
        }
    }
}
```

When `PlayerView` initializes `PlayButton`, it passes a binding of its state
property into the button’s binding property. Applying the `$` prefix to a
property wrapped value returns its [`projectedValue`](/documentation/SwiftUI/State/projectedValue), which for a
state property wrapper returns a binding to the value.

Whenever the user taps the `PlayButton`, the `PlayerView` updates its
`isPlaying` state.

A binding conforms to `Sendable` only if its wrapped value type also
conforms to `Sendable`. It is always safe to pass a sendable binding
between different concurrency domains. However, reading from or writing
to a binding’s wrapped value from a different concurrency domain may or
may not be safe, depending on how the binding was created. SwiftUI will
issue a warning at runtime if it detects a binding being used in a way
that may compromise data safety.

> Note: To create bindings to properties of a type that conforms to the
> <doc://com.apple.documentation/documentation/Observation/Observable>
> protocol, use the ``doc://com.apple.SwiftUI/documentation/SwiftUI/Bindable`` property wrapper. For more information,
> see <doc://com.apple.SwiftUI/documentation/SwiftUI/Migrating-from-the-observable-object-protocol-to-the-observable-macro>.

## Topics

### Creating a binding

[`init ( _ :)`](/documentation/SwiftUI/Binding/init(_:))

Creates a binding by projecting the base value to a hashable value.

[`init(projectedValue:)`](/documentation/SwiftUI/Binding/init(projectedValue:))

Creates a binding from the value of another binding.

[`init ( get : set :)`](/documentation/SwiftUI/Binding/init(get:set:))

Creates a binding with closures that read and write the binding value.

[`constant(_:)`](/documentation/SwiftUI/Binding/constant(_:))

Creates a binding with an immutable value.

### Getting the value

[`wrappedValue`](/documentation/SwiftUI/Binding/wrappedValue)

The underlying value referenced by the binding variable.

[`projectedValue`](/documentation/SwiftUI/Binding/projectedValue)

A projection of the binding value that returns a binding.

[`subscript(dynamicMember:)`](/documentation/SwiftUI/Binding/subscript(dynamicMember:))

Returns a binding to the resulting value of a given key path.

### Managing changes

[`id`](/documentation/SwiftUI/Binding/id)

The stable identity of the entity associated with this instance,
corresponding to the `id` of the binding’s wrapped value.

[`animation(_:)`](/documentation/SwiftUI/Binding/animation(_:))

Specifies an animation to perform when the binding value changes.

[`transaction(_:)`](/documentation/SwiftUI/Binding/transaction(_:))

Specifies a transaction for the binding.

[`transaction`](/documentation/SwiftUI/Binding/transaction)

The binding’s transaction.

## Relationships

### Conforms To

[`DynamicProperty`](/documentation/SwiftUI/DynamicProperty)

[`Copyable`](/documentation/Swift/Copyable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`RandomAccessCollection`](/documentation/Swift/RandomAccessCollection)

[`BidirectionalCollection`](/documentation/Swift/BidirectionalCollection)

[`Sequence`](/documentation/Swift/Sequence)

[`Escapable`](/documentation/Swift/Escapable)

[`Collection`](/documentation/Swift/Collection)

[`Sendable`](/documentation/Swift/Sendable)

[`Identifiable`](/documentation/Swift/Identifiable)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)