menu
TypeScriptstatic get menu(): SearchSuggestionsPlacementSwift declarationstatic var menu: SearchSuggestionsPlacement { get }Search suggestions render inside of a menu attached to the search field.
struct · iOS 16.0+ · SDK 27.1
struct SearchSuggestionsPlacementThe 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.
static get menu(): SearchSuggestionsPlacementSwift declarationstatic var menu: SearchSuggestionsPlacement { get }Search suggestions render inside of a menu attached to the search field.
static get content(): SearchSuggestionsPlacementSwift declarationstatic var content: SearchSuggestionsPlacement { get }Search suggestions render in the main content of the app.
static get automatic(): SearchSuggestionsPlacementSwift declarationstatic 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.
No declarations were skipped in this snapshot.