Skip to content

Shows how to use searchable in SwiftUI to add a search bar on iOS and macOS. Different implementaions showing how to use search suggestions, tokens and search scope

Notifications You must be signed in to change notification settings

gahntpo/SearchExampleApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SearchExampleApp

Shows how to use searchable in SwiftUI to add a search bar on iOS and macOS. Different implementaions showing how to use search suggestions, tokens and search scope

How to add a Search bar - Searchable in SwiftUI

The demo has various implementations for a search bar with the searchable view modifier. These include search suggestions. A detailed description can be found in this blog post: SwiftUI Search Bar: Best Practices and Examples

👀 You can watch me implement these search features in this Youtube tutorial: https://youtu.be/e0eO1di0cPY

Search Text Field with Suggestions on macOS and iOS

You can show search suggestions together with the search text field. On macOS they are shown in a menu below the text field and on iOS they are shown as the main content.

You can also show search suggestions depending on the users input. For example, I prepared a default suggestions array and I only show the ones that match with the search term:

Search Tokens and Search Scope

More advanced filtering can be done with search tokens and search scope which are available with iOS 16+ and macOS 13. A detailed description can be found in these blog posts:

About

Shows how to use searchable in SwiftUI to add a search bar on iOS and macOS. Different implementaions showing how to use search suggestions, tokens and search scope

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages