<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "visionOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/CustomHoverEffect/hoverEffectPhaseOverride(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI17CustomHoverEffectPAAE05hoverE13PhaseOverrideyQrAA0degH0VSgF"
  },
  "title" : "hoverEffectPhaseOverride(_:)"
}
-->

# hoverEffectPhaseOverride(_:)

Returns a new effect with the given `HoverEffectPhaseOverride` applied to
this effect.

```
func hoverEffectPhaseOverride(_ override: HoverEffectPhaseOverride?) -> some CustomHoverEffect
```

## Parameters

`override`

The override to apply to the hover effect’s current phase. If
`nil` is provided, this modifier has no effect.

## Return Value

A new effect with the given override applied.

## Discussion

For example, the following effect will *always* have an opacity of 1.0 since the
override forces the effect to always be active:

```
Color.red
    .hoverEffect(
        .empty
        .hoverEffect { e, isActive, _ in
            e.opacity(isActive ? 1 : 0.5)
        }
        .hoverEffectPhaseOverride(.active)
    )
```

When applied to a `hoverEffectGroup` the override applies to all effects in the
group. Both views in the following example will have an opacity of 1.0:

```
HStack {
    Color.red
        .hoverEffect(
            .empty
            .hoverEffect(in: hoverGroup) { e, isActive, _ in
                e.opacity(isActive ? 1 : 0.5)
            }
            .hoverEffectPhaseOverride(.active)
        )
    Color.red
        .hoverEffect(in: hoverGroup) { e, isActive, _ in
            e.opacity(isActive ? 1 : 0.5)
        }
```

}

Applying overrides to multiple effects in the same group is undefined, due to it
not being clear which override should be applied. Choose one effect in the group
to act as the source effect (as in the example above), or use a separate `.empty`
effect to apply the override:

```
Color.red
    .hoverEffect(
        // apply the override to an empty effect
        .empty
        .hoverEffectGroup(hoverGroup)
        .hoverEffectPhaseOverride(.active)
        // prevent hovering `Color.red` from triggering the group
        .hoverEffectDisabled(true)
    )
    .overlay {
        Rectangle()
            .strokeBorder()
            .hoverEffect(in: hoverGroup) { e, isActive, _ in
                e.opacity(isActive ? 1 : 0.5)
            }
    }
    .padding()
    .background {
        Color.blue
            .hoverEffect(in: hoverGroup) { e, isActive, _ in
                e.opacity(isActive ? 1 : 0.5)
            }
    }
```

---

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)