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

# DragGesture

A dragging motion that invokes an action as the drag-event sequence changes.

```
@MainActor @preconcurrency struct DragGesture
```

## Overview

To recognize a drag gesture on a view, create and configure the gesture, and
then add it to the view using the [`gesture(_:including:)`](/documentation/SwiftUI/View/gesture(_:including:)) modifier.

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

```
struct DragGestureView: View {
    @State private var isDragging = false

    var drag: some Gesture {
        DragGesture()
            .onChanged { _ in self.isDragging = true }
            .onEnded { _ in self.isDragging = false }
    }

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

## Topics

### Creating a drag gesture

[`init(minimumDistance:coordinateSpace:)`](/documentation/SwiftUI/DragGesture/init(minimumDistance:coordinateSpace:)-8ffe5)

Creates a dragging gesture with the minimum dragging distance before the
gesture succeeds and the coordinate space of the gesture’s location.

[`init(minimumDistance:coordinateSpace:)`](/documentation/SwiftUI/DragGesture/init(minimumDistance:coordinateSpace:))

Creates a dragging gesture with the minimum dragging distance before the
gesture succeeds and the coordinate space of the gesture’s location.

[`init(minimumDistance:coordinateSpace3D:)`](/documentation/SwiftUI/DragGesture/init(minimumDistance:coordinateSpace3D:))

Creates a dragging gesture with the minimum dragging distance before the
gesture succeeds and the coordinate space of the gesture’s location.

[`init(minimumDistance:coordinateSpace:inputKinds:)`](/documentation/SwiftUI/DragGesture/init(minimumDistance:coordinateSpace:inputKinds:))

Creates a dragging gesture with the minimum dragging distance before the
gesture succeeds, the coordinate space of the gesture’s location, and
the input kinds the gesture recognizes.

[`minimumDistance`](/documentation/SwiftUI/DragGesture/minimumDistance)

The minimum dragging distance before the gesture succeeds.

[`coordinateSpace`](/documentation/SwiftUI/DragGesture/coordinateSpace)

The coordinate space in which to receive location values.

### Getting the gesture’s value

[`DragGesture.Value`](/documentation/SwiftUI/DragGesture/Value)

The attributes of a drag gesture.

### Deprecated initializers

[`init(minimumDistance:coordinateSpace:)`](/documentation/SwiftUI/DragGesture/init(minimumDistance:coordinateSpace:)-3804h)

Creates a dragging gesture with the minimum dragging distance before the
gesture succeeds and the coordinate space of the gesture’s location.



---

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)