searchable

Marks this view as searchable, which configures the display of a search field.

View ModifieriOS 17.0+macOS 14.0+

Overloads

32 ways to call compose().searchable(). Each is one SwiftUI overload, picked by the arguments you pass.

React
compose().searchable({
  text: Binding<string>,
  editableTokens: Binding<unknown[]>,
  isPresented: Binding<boolean>,
  placement?: SwiftUI.SearchFieldPlacement,
  prompt: string,
  token: ReactNode | ((arg0: Binding<unknown>) => ReactNode),
})
Swift
@export(implementation) nonisolated func searchable<C>(
    text: Binding<String>,
    editableTokens: Binding<C>,
    isPresented: Binding<Bool>,
    placement: SearchFieldPlacement = .automatic,
    prompt: LocalizedStringResource,
    @ContentBuilder token: @escaping (Binding<C.Element>) -> some View
) -> some View
where C : RandomAccessCollection, C : RangeReplaceableCollection, C.Element : Identifiable

Parameters

  • options.text*Binding<string>

    The text to display and edit in the search field.

  • options.editableTokens*Binding<unknown[]>

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

  • options.isPresented*Binding<boolean>

    A Binding which controls the presented state of search.

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

  • options.prompt*string

    Text resource for the localized prompt of the search field which provides users with guidance on what to search for.

  • options.token*ReactNode | ((arg0: Binding<unknown>) => ReactNode)

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

Discussion

For more information about using searchable modifiers, see doc:Adding-a-search-interface-to-your-app.

See also

More in Navigation.