searchToolbarBehavior

Configures the behavior for search in the toolbar.

View ModifieriOS 26.0+macOS 26.0+tvOS 26.0+watchOS 26.0+visionOS 26.0+searchToolbarBehavior(_:) in SwiftUI

Declaration

React
compose().searchToolbarBehavior(
  behavior: SwiftUI.SearchToolbarBehavior
)
Swift
nonisolated func searchToolbarBehavior(
    _ behavior: SearchToolbarBehavior
) -> some View

Parameters

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 View.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(.minimized)
}

See also

More in Navigation.