hoverEffectDisabled

Adds a condition that controls whether this view can display hover effects.

View ModifieriOS 17.0+tvOS 17.0+visionOS 1.0+hoverEffectDisabled(_:) in SwiftUI

Declaration

React
compose().hoverEffectDisabled(disabled?: boolean)
Swift
nonisolated func hoverEffectDisabled(
    _ disabled: Bool = true
) -> some View

Parameters

  • disabledboolean

    A Boolean value that determines whether this view can display hover effects.

Return value

A view that controls whether hover effects can be displayed in this view.

Discussion

The higher views in a view hierarchy can override the value you set on this view. In the following example, the button does not display a hover effect because the outer hoverEffectDisabled(_:) modifier overrides the inner one:

HStack {
    Button("Press") {}
        .hoverEffectDisabled(false)
}
.hoverEffectDisabled(true)

See also

More in Gestures and input.