how to add a search in the tab bar

Asked on 2025-07-31

@wwdc25

1 search

To add a search feature in the tab bar of your app, you can follow the guidance provided in the WWDC sessions. Here are the steps for both UIKit and SwiftUI:

UIKit

In a UIKit app, you can include a distinct tab for search in the tab bar. When the search tab is tapped, the search button expands into a search field, and the other buttons collapse. This setup is ideal for providing search suggestions and allowing users to start searching immediately. To have the search field activate automatically when the search tab is tapped, set automaticallyActivateSearch to true on that tab. For more details, you can refer to the session Build a UIKit app with the new design.

SwiftUI

In a SwiftUI app, you can set a search role on one of your tabs and place a searchable modifier on your tab view. When the search tab is selected, a search field takes the place of the tab bar, and the content of the tab is shown. This allows users to interact with browsing suggestions or tap on the search field to bring up the keyboard. For more information, see the session Build a SwiftUI app with the new design.

These patterns provide flexibility and control over the search experience in your app, making it easier for users to find what they are looking for.