<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/HoverPhase",
  "metadataVersion" : "0.1.0",
  "role" : "Enumeration",
  "symbol" : {
    "kind" : "Enumeration",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI10HoverPhaseO"
  },
  "title" : "HoverPhase"
}
-->

# HoverPhase

The current hovering state and value of the pointer.

```
@frozen enum HoverPhase
```

## Overview

When you use the [`onContinuousHover(coordinateSpace:perform:)`](/documentation/SwiftUI/View/onContinuousHover(coordinateSpace:perform:))
modifier, you can handle the hovering state using the `action` closure.
SwiftUI calls the closure with a phase value to indicate the current
hovering state. The following example updates `hoverLocation` and
`isHovering` based on the phase provided to the closure:

```
@State private var hoverLocation: CGPoint = .zero
@State private var isHovering = false

var body: some View {
    VStack {
        Color.red
            .frame(width: 400, height: 400)
            .onContinuousHover { phase in
                switch phase {
                case .active(let location):
                    hoverLocation = location
                    isHovering = true
                case .ended:
                    isHovering = false
                }
            }
            .overlay {
                Rectangle()
                    .frame(width: 50, height: 50)
                    .foregroundColor(isHovering ? .green : .blue)
                    .offset(x: hoverLocation.x, y: hoverLocation.y)
            }
    }
}
```

## Topics

### Getting hover phases

[`HoverPhase.active(_:)`](/documentation/SwiftUI/HoverPhase/active(_:))

The pointer’s location moved to the specified point within the view.

[`HoverPhase.ended`](/documentation/SwiftUI/HoverPhase/ended)

The pointer exited the view.



---

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)