<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/CustomHoverEffect",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI17CustomHoverEffectP"
  },
  "title" : "CustomHoverEffect"
}
-->

# CustomHoverEffect

A type that represents how a view should change when a pointer hovers
over a view, or when someone looks at the view.

```
protocol CustomHoverEffect
```

## Overview

Custom hover effects apply their inactive values when the effect is
inactive, and their active values when the effect is active. For example,
the following effect causes a view to be partially transparent when
inactive, but animate to fully opaque when active:

```
struct FadeInHoverEffect: CustomHoverEffect {
    func body(content: Content) -> some CustomHoverEffect {
        content.hoverEffect { effect, isActive, proxy in
            effect.animation(.easeOut) {
                $0.opacity(isActive ? 1 : 0.5)
            }
        }
    }
}
```

This effect can be applied to a view using the `hoverEffect(_:)` modifier:

```
Color.red
    .hoverEffect(FadeInHoverEffect())
```

Hover effects do not affect a view’s layout, and may be applied to a view
out-of-process. Therefore an effect’s current phase may not be visible
within your app.

## Topics

### Getting built-in hover effects

[`automatic`](/documentation/SwiftUI/CustomHoverEffect/automatic)

The default hover effect based on the surrounding context.

[`empty`](/documentation/SwiftUI/CustomHoverEffect/empty)

An effect that applies no changes when hovered.

[`highlight`](/documentation/SwiftUI/CustomHoverEffect/highlight)

A hover effect that highlights views using a light source to indicate
position.

[`lift`](/documentation/SwiftUI/CustomHoverEffect/lift)

A hover effect that slides the pointer under the view and disappears as
the view scales up and gains a shadow.

### Creating custom hover effects

[`hoverEffect(_:in:isEnabled:)`](/documentation/SwiftUI/CustomHoverEffect/hoverEffect(_:in:isEnabled:))

Applies this effect in parallel with the given `effect`.

[`hoverEffect(in:isEnabled:body:)`](/documentation/SwiftUI/CustomHoverEffect/hoverEffect(in:isEnabled:body:)-swift.method)

Applies a hover effect based on the current phase.

[`hoverEffectGroup(_:)`](/documentation/SwiftUI/CustomHoverEffect/hoverEffectGroup(_:)-swift.method)

Activates this effect as part of an effect group.

[`hoverEffectGroup(id:in:behavior:)`](/documentation/SwiftUI/CustomHoverEffect/hoverEffectGroup(id:in:behavior:)-swift.method)

Activates this effect as part of an effect group.

[`hoverEffectDisabled(_:)`](/documentation/SwiftUI/CustomHoverEffect/hoverEffectDisabled(_:))

Disables this hover effect.

### Supporting types

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

The default hover effect based on the surrounding context.

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

A base hover effect used to build additional effects.

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

A hover effect that highlights views using a light source to indicate
position.

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

A hover effect that slides the pointer under the view and disappears as the
view scales up and gains a shadow.



---

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)