One Logo Pool Ball
SwiftUI · IOS API REFERENCE

SearchSuggestionsPlacement

struct · iOS 16.0+ · SDK 27.1

struct SearchSuggestionsPlacement

The ways that SwiftUI displays search suggestions. You can influence which modes SwiftUI displays search suggestions for by using the ``View/searchSuggestions(_:for:)`` modifier: enum FruitSuggestion: String, Identifiable { case apple, banana, orange var id: Self { self } } @State private var text = "" @State private var suggestions: [FruitSuggestion] = [] var body: some View { MainContent() .searchable(text: $text) { ForEach(suggestions) { suggestion in Text(suggestion.rawValue) .searchCompletion(suggestion.rawValue) } .searchSuggestions(.hidden, for: .content) } } In the above example, SwiftUI only displays search suggestions in a suggestions menu. You might want to do this when you want to render search suggestions in a container, like inline with your own set of search results. You can get the current search suggestion placement by querying the ``EnvironmentValues/searchSuggestionsPlacement`` environment value in your search suggestions.

Members (3)

get · iOS 16.0+

menu

TypeScript
static get menu(): SearchSuggestionsPlacement
Swift declaration
static var menu: SearchSuggestionsPlacement { get }

Search suggestions render inside of a menu attached to the search field.

get · iOS 16.0+

content

TypeScript
static get content(): SearchSuggestionsPlacement
Swift declaration
static var content: SearchSuggestionsPlacement { get }

Search suggestions render in the main content of the app.

get · iOS 16.0+

automatic

TypeScript
static get automatic(): SearchSuggestionsPlacement
Swift declaration
static var automatic: SearchSuggestionsPlacement { get }

Search suggestions render automatically based on the surrounding context. The behavior varies by platform: * In iOS and iPadOS, suggestions render as a list overlaying the main content of the app. * In macOS, suggestions render in a menu. * In tvOS, suggestions render as a row underneath the search field. * In watchOS, suggestions render in a list pushed onto the containing navigation stack.

Skipped declarations

No declarations were skipped in this snapshot.

All SwiftUI types →