<!--
{
  "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(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE13searchFocusedyQrAA10FocusStateV7BindingVySb_GF"
  },
  "title" : "searchFocused(_:)"
}
-->

# searchFocused(_:)

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

```
nonisolated func searchFocused(_ binding: FocusState<Bool>.Binding) -> some View
```

## Parameters

`binding`

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
[`searchFocused(_:equals:)`](/documentation/SwiftUI/View/searchFocused(_:equals:)) 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)