Instance Method


Sets whether this view is focusable and, if so, adds an action to perform when the view comes into focus.


func focusable(_ isFocusable: Bool = true, onFocusChange: @escaping (Bool) -> Void = { _ in }) -> some View



A Boolean value that indicates whether this view is focusable.


A closure that’s called whenever this view either gains or loses focus. The Boolean parameter to onFocusChange is true when the view is in focus; otherwise, it’s false.

Return Value

A view that sets whether a view is focusable, and triggers onFocusChange when the view gains or loses focus.

See Also

Handling View Hover and Focus

func onHover(perform: (Bool) -> Void) -> View

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


Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software