---
title: Binding
framework: swiftui
role: symbol
role_heading: Structure
path: swiftui/binding
---

# Binding

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

## Declaration

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

## Mentioned in

Performing a search operation Understanding the navigation stack Adding a search interface to your app Managing user interface state Managing search interface activation

## Overview

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 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, 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 Observable protocol, use the Bindable property wrapper. For more information, see Migrating from the Observable Object protocol to the Observable macro.

## Topics

### Creating a binding

- [init(_:)](swiftui/binding/init(_:).md)
- [init(projectedValue:)](swiftui/binding/init(projectedvalue:).md)
- [init(get:set:)](swiftui/binding/init(get:set:).md)
- [constant(_:)](swiftui/binding/constant(_:).md)

### Getting the value

- [wrappedValue](swiftui/binding/wrappedvalue.md)
- [projectedValue](swiftui/binding/projectedvalue.md)
- [subscript(dynamicMember:)](swiftui/binding/subscript(dynamicmember:).md)

### Managing changes

- [id](swiftui/binding/id.md)
- [animation(_:)](swiftui/binding/animation(_:).md)
- [transaction(_:)](swiftui/binding/transaction(_:).md)
- [transaction](swiftui/binding/transaction.md)

### Subscripts

- [subscript(_:)](swiftui/binding/subscript(_:).md)

### Default Implementations

- [Identifiable Implementations](swiftui/binding/identifiable-implementations.md)

## Relationships

### Conforms To

- [BidirectionalCollection](swift/bidirectionalcollection.md)
- [Collection](swift/collection.md)
- [Copyable](swift/copyable.md)
- [DynamicProperty](swiftui/dynamicproperty.md)
- [Escapable](swift/escapable.md)
- [Identifiable](swift/identifiable.md)
- [RandomAccessCollection](swift/randomaccesscollection.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)
- [Sequence](swift/sequence.md)

## See Also

### Creating and sharing view state

- [Managing user interface state](swiftui/managing-user-interface-state.md)
- [State()](swiftui/state().md)
- [State(initialValue:)](swiftui/state(initialvalue:).md)
- [State(wrappedValue:)](swiftui/state(wrappedvalue:).md)
- [State](swiftui/state.md)
- [Bindable](swiftui/bindable.md)
