Contents

hoverEffectDisabled(_:)

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

Declaration

nonisolated func hoverEffectDisabled(_ disabled: Bool = true) -> some View

Parameters

  • disabled:

    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

Responding to hover events