searchFocused

Modifies this view by binding the focus state of the search field associated with the nearest searchable modifier to the given Boolean value.

View ModifieriOS 18.0+macOS 15.0+visionOS 2.0+

Overloads

2 ways to call compose().searchFocused(). Each is one SwiftUI overload, picked by the arguments you pass.

React
compose().searchFocused(binding: Binding<boolean>)
Swift
nonisolated func searchFocused(
    _ binding: FocusState<Bool>.Binding
) -> some View

Parameters

  • binding*Binding<boolean>

    The focus state to bind. When focus moves to the associated search field, the binding sets the bound value to true. If a caller sets the value to true programmatically, then focus moves to the search field. When focus leaves the search field, the binding sets the value to false. If a caller sets the value to false, SwiftUI automatically dismisses focus.

Return value

The modified view.

Discussion

To control focus by matching a non-boolean value, use the View.searchFocused(_:equals:) modifier instead.

For more information about using searchable modifiers, refer to doc:Adding-a-search-interface-to-your-app.

See also

More in Focus.