<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.4.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/searchScopes(_:scopes:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE12searchScopes_6scopesQrAA7BindingVyqd__G_qd_0_yXEtSHRd__AaBRd_0_r0_lF"
  },
  "title" : "searchScopes(_:scopes:)"
}
-->

# searchScopes(_:scopes:)

Configures the search scopes for this view.

```
nonisolated func searchScopes<V, S>(_ scope: Binding<V>, @ContentBuilder scopes: () -> S) -> some View where V : Hashable, S : View
```

## Parameters

`scope`

The active scope of the search field.

`scopes`

A content builder that represents the scoping options
SwiftUI uses to populate a [`Picker`](/documentation/SwiftUI/Picker).

## Discussion

To enable people to narrow the scope of their searches, you can
create a type that represents the possible scopes, and then create a
state variable to hold the current selection. For example, you can
scope the product search to just fruits or just vegetables:

```
enum ProductScope {
    case fruit
    case vegetable
}

@State private var scope: ProductScope = .fruit
```

Provide a binding to the scope, as well as a view that represents each
scope:

```
ProductList()
    .searchable(text: $text, tokens: $tokens) { token in
        switch token {
        case .apple: Text("Apple")
        case .pear: Text("Pear")
        case .banana: Text("Banana")
        }
    }
    .searchScopes($scope) {
        Text("Fruit").tag(ProductScope.fruit)
        Text("Vegetable").tag(ProductScope.vegetable)
    }
```

SwiftUI uses this binding and view to add a [`Picker`](/documentation/SwiftUI/Picker) with the search
field. In iOS, iPadOS, macOS, and tvOS, the picker appears below the
search field when search is active. To ensure that the picker operates
correctly, match the type of the scope binding with the type of each
view’s tag. Then modify your search to account for the current value of
the `scope` state property.

For more information about using searchable modifiers, see
[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)