<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/EnvironmentValues/isSearching",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI17EnvironmentValuesVAAE11isSearchingSbvp"
  },
  "title" : "isSearching"
}
-->

# isSearching

A Boolean value that indicates when the user is searching.

```
var isSearching: Bool { get }
```

## Discussion

You can read this value like any of the other [`EnvironmentValues`](/documentation/SwiftUI/EnvironmentValues),
by creating a property with the [`Environment`](/documentation/SwiftUI/Environment) property wrapper:

```
@Environment(\.isSearching) private var isSearching
```

Get the value to find out when the user interacts with a search
field that’s produced by one of the searchable modifiers, like
[`searchable(text:placement:prompt:)`](/documentation/SwiftUI/View/searchable(text:placement:prompt:)):

```
struct SearchingExample: View {
    @State private var searchText = ""

    var body: some View {
        NavigationStack {
            SearchedView()
                .searchable(text: $searchText)
        }
    }
}

struct SearchedView: View {
    @Environment(\.isSearching) private var isSearching

    var body: some View {
        Text(isSearching ? "Searching!" : "Not searching.")
    }
}
```

When the user first taps or clicks in a search field, the
`isSearching` property becomes `true`. When the user cancels the
search operation, the property becomes `false`. To programmatically
set the value to `false` and dismiss the search operation, use
[`dismissSearch`](/documentation/SwiftUI/EnvironmentValues/dismissSearch).

> Important: Access the value from inside the searched view, as the
> example above demonstrates, rather than from the searched view’s
> parent. SwiftUI sets the value in the environment of the view that
> you apply the searchable modifier to, and doesn’t propagate the
> value up the view hierarchy.

---

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)