Search
Enable people to search for text or other content within your app.
Overview
To present a search field in your app, create and manage storage for search text and optionally for discrete search terms known as tokens. Then bind the storage to the search field by applying the searchable view modifier to a view in your app.
[Image]
As people interact with the field, they implicitly modify the underlying storage and, thereby, the search parameters. Your app correspondingly updates other parts of its interface. To enhance the search interaction, you can also:
Offer suggestions during search, for both text and tokens.
Implement search scopes that help people to narrow the search space.
Detect when people activate the search field, and programmatically dismiss the search field using environment values.
For design guidance, see Searching in the Human Interface Guidelines.
Topics
Searching your app’s data model
Adding a search interface to your appPerforming a search operationsearchable(text:placement:prompt:)searchable(text:tokens:placement:prompt:token:)searchable(text:editableTokens:placement:prompt:token:)SearchFieldPlacement
Making search suggestions
Suggesting search termssearchSuggestions(_:)searchSuggestions(_:for:)searchCompletion(_:)searchable(text:tokens:suggestedTokens:placement:prompt:token:)SearchSuggestionsPlacement
Limiting search scope
Detecting, activating, and dismissing search
Managing search interface activationisSearchingdismissSearchDismissSearchActionsearchable(text:isPresented:placement:prompt:)searchable(text:tokens:isPresented:placement:prompt:token:)searchable(text:editableTokens:isPresented:placement:prompt:token:)searchable(text:tokens:suggestedTokens:isPresented:placement:prompt:token:)