onHover

Adds an action to perform when the user moves the pointer over or away from the view's frame.

View ModifieriOS 13.4+macOS 10.15+onHover(perform:) in SwiftUI

Declaration

React
compose().onHover({
  perform: (arg0: boolean) => void,
})
Swift
nonisolated func onHover(
    perform action: @escaping (Bool) -> Void
) -> some View

Parameters

  • options.perform*(arg0: boolean) => void

Return value

A view that triggers action when the pointer enters or exits this view's frame.

Discussion

Calling this method defines a region for detecting pointer movement with the size and position of this view.

See also

More in Events and lifecycle.