<!--
{
  "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/GestureState",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI12GestureStateV"
  },
  "title" : "GestureState"
}
-->

# GestureState

A property wrapper type that updates a property while the user performs a
gesture and resets the property back to its initial state when the gesture
ends.

```
@propertyWrapper @frozen struct GestureState<Value>
```

## Overview

Declare a property as `@GestureState`, pass as a binding to it as a
parameter to a gesture’s [`updating(_:body:)`](/documentation/SwiftUI/Gesture/updating(_:body:)) callback, and receive
updates to it. A property that’s declared as `@GestureState` implicitly
resets when the gesture becomes inactive, making it suitable for tracking
transient state.

Add a long-press gesture to a [`Circle`](/documentation/SwiftUI/Circle), and update the interface during
the gesture by declaring a property as `@GestureState`:

```
struct SimpleLongPressGestureView: View {
    @GestureState private var isDetectingLongPress = false

    var longPress: some Gesture {
        LongPressGesture(minimumDuration: 3)
            .updating($isDetectingLongPress) { currentState, gestureState, transaction in
                gestureState = currentState
            }
    }

    var body: some View {
        Circle()
            .fill(self.isDetectingLongPress ? Color.red : Color.green)
            .frame(width: 100, height: 100, alignment: .center)
            .gesture(longPress)
    }
}
```

## Topics

### Creating a gesture state

[`init(initialValue:)`](/documentation/SwiftUI/GestureState/init(initialValue:))

Creates a view state that’s derived from a gesture with an initial
value.

[`init(initialValue:reset:)`](/documentation/SwiftUI/GestureState/init(initialValue:reset:))

Creates a view state that’s derived from a gesture with an initial state
value and a closure that provides a transaction to reset it.

[`init(initialValue:resetTransaction:)`](/documentation/SwiftUI/GestureState/init(initialValue:resetTransaction:))

Creates a view state that’s derived from a gesture with an initial state
value and a transaction to reset it.

[`init(reset:)`](/documentation/SwiftUI/GestureState/init(reset:))

Creates a view state that’s derived from a gesture with a closure that
provides a transaction to reset it.

[`init(resetTransaction:)`](/documentation/SwiftUI/GestureState/init(resetTransaction:))

Creates a view state that’s derived from a gesture with a transaction to
reset it.

[`init(wrappedValue:)`](/documentation/SwiftUI/GestureState/init(wrappedValue:))

Creates a view state that’s derived from a gesture.

[`init(wrappedValue:reset:)`](/documentation/SwiftUI/GestureState/init(wrappedValue:reset:))

Creates a view state that’s derived from a gesture with a wrapped state
value and a closure that provides a transaction to reset it.

[`init(wrappedValue:resetTransaction:)`](/documentation/SwiftUI/GestureState/init(wrappedValue:resetTransaction:))

Creates a view state that’s derived from a gesture with a wrapped state
value and a transaction to reset it.

### Getting the state

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

The wrapped value referenced by the gesture state property.

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

A binding to the gesture state property.



---

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)