Contents

searchable(text:tokens:suggestedTokens:isPresented:placement:prompt:token:)

Marks this view as searchable with text, tokens, and suggestions, as well as programmatic presentation.

Declaration

nonisolated func searchable<C, T, S>(text: Binding<String>, tokens: Binding<C>, suggestedTokens: Binding<C>, isPresented: Binding<Bool>, placement: SearchFieldPlacement = .automatic, prompt: S, @ViewBuilder token: @escaping (C.Element) -> T) -> some View where C : MutableCollection, C : RandomAccessCollection, C : RangeReplaceableCollection, T : View, S : StringProtocol, C.Element : Identifiable

Parameters

  • text:

    The text to display and edit in the search field.

  • tokens:

    A collection of tokens to display and edit in the search field.

  • suggestedTokens:

    A collection of tokens to display as suggestions.

  • isPresented:

    A Binding that controls the presented state of search.

  • placement:

    The preferred placement of the search field within the containing view hierarchy.

  • prompt:

    A string representing the prompt of the search field which provides users with guidance on what to search for.

  • token:

    A view builder that creates a view given an element in tokens.

Discussion

For more information about using searchable modifiers, see Adding a search interface to your app. For information about presenting a search field programmatically, see Managing search interface activation.

See Also

Detecting, activating, and dismissing search