<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "visionOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/searchFocused(_:equals:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE13searchFocused_6equalsQrAA10FocusStateV7BindingVyqd___G_qd__tSHRd__lF"
  },
  "title" : "searchFocused(_:equals:)"
}
-->

# searchFocused(_:equals:)

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

```
nonisolated func searchFocused<V>(_ binding: FocusState<V>.Binding, equals value: V) -> some View where V : Hashable
```

## Parameters

`binding`

The state binding to register. When focus moves to the
associated search field, the binding sets the bound value to the
corresponding match value. If a caller sets the state value
programmatically to the matching value, then focus moves to the
search field. When focus leaves the search field, the binding sets
the bound value to `nil`. If a caller sets the value to `nil`,
SwiftUI automatically dismisses focus.

`value`

The value to match against when determining whether the
binding should change.

## Return Value

The modified view.

## Discussion

To control focus by matching a simple boolean condition, use the
[`searchFocused(_:)`](/documentation/SwiftUI/View/searchFocused(_:)) modifier instead.

For more information about using searchable modifiers, refer to
[Adding a search interface to your app](/documentation/SwiftUI/Adding-a-search-interface-to-your-app).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)