<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/defaultHoverEffect(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE18defaultHoverEffectyQrAA0eF0VSgF::OverloadGroup"
  },
  "title" : "defaultHoverEffect(_:)"
}
-->

# defaultHoverEffect(_:)

Sets the default hover effect to use for views within this view.

```
nonisolated func defaultHoverEffect(_ effect: HoverEffect?) -> some View
```

## Parameters

`effect`

The default hover effect to use for views within
this view.

## Return Value

A view that uses this effect as the default hover effect.

## Discussion

Use this modifier to set a specific hover effect for all views with the
[`hoverEffect(_:)`](/documentation/SwiftUI/View/hoverEffect(_:)) modifier applied within a view. The default
effect is typically used when no [`HoverEffect`](/documentation/SwiftUI/HoverEffect) was provided or if
[`automatic`](/documentation/SwiftUI/HoverEffect/automatic) is specified.

For example, this view uses [`highlight`](/documentation/SwiftUI/HoverEffect/highlight) for both the red
and green Color views:

```
HStack {
    Color.red.hoverEffect()
    Color.green.hoverEffect()
}
.defaultHoverEffect(.highlight)
```

This also works for customizing the default hover effect in views like
[`Button`](/documentation/SwiftUI/Button)s when using a SwiftUI-defined style like
`ButtonStyle/bordered`, which can provide a hover effect by default.
For example, this view replaces the hover effect for a [`Button`](/documentation/SwiftUI/Button) with
[`highlight`](/documentation/SwiftUI/HoverEffect/highlight):

```
Button("Next") {}
    // perform action
}
.buttonStyle(.bordered)
.defaultHoverEffect(.highlight)
```

Use a `nil` effect to indicate that the default hover effect should not
be modified.

---

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)