<!--
{
  "availability" : [
    "macOS: 15.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/WindowDragGesture",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI17WindowDragGestureV"
  },
  "title" : "WindowDragGesture"
}
-->

# WindowDragGesture

A gesture that recognizes the motion of and handles dragging a window.

```
nonisolated struct WindowDragGesture
```

## Overview

To recognize a window drag gesture on a view, create and configure the
gesture, and then add it to the view using the [`gesture(_:isEnabled:)`](/documentation/SwiftUI/View/gesture(_:isEnabled:))
modifier. Consider also letting the gesture 
[handle events that activate the
containing window](doc://com.apple.documentation/documentation/SwiftUI/View/allowsWindowActivationEvents(_:))
so that dragging the containing window works even when it’s inactive.

To add a window drag gesture to a [`Circle`](/documentation/SwiftUI/Circle) and change its color while a
user performs the window drag gesture:

```
struct MyView: View {
    @GestureState var isDraggingWindow = false

    var dragWindow: some Gesture {
        WindowDragGesture()
            .updating($isDraggingWindow) { _, state, _ in
                state = true
            }
    }

    var body: some View {
        Circle()
            .fill(isDraggingWindow ? Color.green : .blue)
            .frame(width: 50, height: 50)
            .gesture(dragWindow)
            .allowsWindowActivationEvents()
    }
}
```

## Topics

### Creating a window drag gesture

[`init()`](/documentation/SwiftUI/WindowDragGesture/init())

Creates a window drag gesture.

### Getting the gesture’s value

[`struct Value`](/documentation/SwiftUI/WindowDragGesture/Value)

The properties of a window drag gesture.

## Relationships

### Conforms To

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

---

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)