---
title: DragGesture
framework: swiftui
role: symbol
role_heading: Structure
path: swiftui/draggesture
---

# DragGesture

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

## Declaration

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

## Mentioned in

Composing SwiftUI gestures

## Overview

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:) modifier. Add a drag gesture to a 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:)](swiftui/draggesture/init(minimumdistance:coordinatespace:)-8ffe5.md)
- [init(minimumDistance:coordinateSpace:)](swiftui/draggesture/init(minimumdistance:coordinatespace:).md)
- [init(minimumDistance:coordinateSpace3D:)](swiftui/draggesture/init(minimumdistance:coordinatespace3d:).md)
- [init(minimumDistance:coordinateSpace:inputKinds:)](swiftui/draggesture/init(minimumdistance:coordinatespace:inputkinds:).md)
- [minimumDistance](swiftui/draggesture/minimumdistance.md)
- [coordinateSpace](swiftui/draggesture/coordinatespace.md)

### Getting the gesture’s value

- [DragGesture.Value](swiftui/draggesture/value.md)

### Deprecated initializers

- [init(minimumDistance:coordinateSpace:)](swiftui/draggesture/init(minimumdistance:coordinatespace:)-3804h.md)

## Relationships

### Conforms To

- [Gesture](swiftui/gesture.md)

## See Also

### Recognizing gestures that change over time

- [gesture(_:)](swiftui/view/gesture(_:).md)
- [gesture(_:isEnabled:)](swiftui/view/gesture(_:isenabled:).md)
- [gesture(_:name:isEnabled:)](swiftui/view/gesture(_:name:isenabled:).md)
- [gesture(_:including:)](swiftui/view/gesture(_:including:).md)
- [WindowDragGesture](swiftui/windowdraggesture.md)
- [MagnifyGesture](swiftui/magnifygesture.md)
- [RotateGesture](swiftui/rotategesture.md)
- [RotateGesture3D](swiftui/rotategesture3d.md)
- [GestureMask](swiftui/gesturemask.md)
