<!--
{
  "availability" : [
    "iOS: 13.4.0 -",
    "iPadOS: 13.4.0 -",
    "macCatalyst: 13.4.0 -",
    "macOS: 10.15.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/onHover(perform:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE7onHover7performQrySbc_tF"
  },
  "title" : "onHover(perform:)"
}
-->

# onHover(perform:)

Adds an action to perform when the user moves the pointer over or away
from the view’s frame.

```
nonisolated func onHover(perform action: @escaping (Bool) -> Void) -> some View
```

## Parameters

`action`

The action to perform whenever the pointer enters or
exits this view’s frame. If the pointer is in the view’s frame, the
`action` closure passes `true` as a parameter; otherwise, `false`.

## Return Value

A view that triggers `action` when the pointer enters or
exits this view’s frame.

## Discussion

Calling this method defines a region for detecting pointer movement with
the size and position of this 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)