searchToolbarBehavior(_:)
Configures the behavior for search in the toolbar.
Declaration
nonisolated func searchToolbarBehavior(_ behavior: SearchToolbarBehavior) -> some View
Discussion
This modifier can be used to change the default behavior of a search field that appears in the toolbar. Place this modifier after the searchable(text:isPresented:placement:prompt:) modifier that renders search in the toolbar.
On iPhone, the search field in the bottom toolbar can be configured to appear as a button-like control when inactive:
@State private var searchText = ""
NavigationStack {
RecipeList()
.searchable($searchText)
.searchToolbarBehavior(.minimize)
}