Search

Search helps people reach content by describing what they want instead of browsing through every destination. Placing search with the page or navigation it affects makes its scope easier to understand.

Bind the query to app state with .searchable(); the app decides which results to show.

nav(section)
    .style(NavStyle::Sidebar)
    .searchable(Search::new(query).prompt(res::str::search_sections())) // query: Signal<String>, two-way
    .items(nav_items(move || destinations_matching(query.get()), row))

Typing updates the query signal; writing the signal updates the field without rebuilding it.

The UI snippets use generated res::str accessors from an app’s Fluent catalog; see the example messages and catalog setup.

Modifiers

spellingwhat it does
.searchable(Search::new(query))makes the surface searchable, bound two-way to query (a Signal<String> or any binding)
Search::prompt(text)the empty-state prompt; a localized string or closure follows the language and its signals
Search::placement(p)a placement preference (see below)
Search::reveal(SearchReveal)how the field comes and goes on a phone (see below)
Search::scopes(scope, titles)scope selection metadata; see the rendering limit below
Search::suggestions(f)completions for the current text

Find commands

Bind the app’s localized Find command to day::focus_search(), normally Cmd-F on macOS or Ctrl-F elsewhere. It focuses the active searchable navigation surface and keeps its query.

Placement and reveal

SearchPlacement::Automatic uses the window toolbar where it supports search, otherwise an inline field on the navigation surface. Toolbar and Inline request a placement; the toolkit can fall back when it cannot honor the request. A narrow desktop window can retain toolbar search.

Search::reveal controls a navigation surface’s search field:

PolicyBehavior
Always (default)Keeps the field visible.
ScrollsLets supporting mobile toolkits collapse the field and title as the list scrolls.
OnPullRequests an initially hidden field. Android honors this; UIKit treats it as Scrolls.

Desktop toolbar search is unaffected by reveal policy. On UIKit, scrolling and returning to the top control the field’s visibility. On Android, tapping the scrolling search bar opens its search view with the navigation list as results; choosing a result or pressing Back collapses the search view. The query still belongs to the app.

Search scopes

Search::scopes accepts scope titles and a selection binding, but the toolkits do not currently render a scope bar. Use a separate picker when the app needs visible search filters.

Suggestions complete the field

On a navigation surface the list is the result set. So Search::suggestions offers completions that fill the field; it does not open an overlay of results, which would cover the list it is narrowing.

Completion presentation depends on the toolkit:

toolkitcompletions
linux-qtQCompleter (native popup, case-insensitive)
web-dom<datalist> (the browser’s own popup)
windows-winuiAutoSuggestBox.ItemsSource
ios-uikitUISearchResultsUpdating, at any placement — see below
macos-appkitnone. NSSearchField’s menu is a recents list, not completions for the current text, so Day does not present it as one
linux-gtknone. GTK4 deprecated GtkEntryCompletion and GtkSearchEntry has no replacement
android-material, harmony-arkuiwith the Inline placement

Choosing a suggestion puts it in the field and emits the same change any keystroke would, so an app that only reads query needs no extra handling. Event::SearchSuggestionChosen says which one, for an app that wants to act on the choice itself.

Searchable content

A navigation surface (Nav::searchable), and a nav_stack page (Decorate::searchable, below). For a field within ordinary content, use Search field.

A page that lists something the user searches, such as a catalog or a mailbox, declares the field on itself, as it declares its .toolbar(…):

results_page(feed)
    .searchable(
        Search::new(query)
            .prompt(res::str::search())
            .on_submit(move |text| run_search(text))
            .available(move || feed_loaded.get() && feed_can_search.get()),
    )

The field is the reserved day::search item on the page’s own chrome, so it follows the page: it shows while the page is on top of its stack and leaves when another page is pushed over it or the page is popped. Each toolkit draws it where its platform puts a page’s search:

toolkitpage searchsubmit
ios-uikitthe page’s own UISearchController on its navigationItem, stacked under the title as Mail’s mailbox does: shown when the field arrives, then hidden on scroll and back on a pull; Cancel clears the query. One controller per page for the page’s life, so a page covered by a push keeps its field and textthe keyboard’s Search key
android-materiala collapsible androidx.appcompat.widget.SearchView action on the page’s app bar: the magnifier expands into a field across the bar; the collapse arrow or system Back closes it and clears the querythe keyboard’s Search key
harmony-arkuian ArkUI Search at the top of the showing page, under its title barSearch.onSubmit
macos-appkitthe NSSearchToolbarItem at the trailing edge of the window toolbarReturn or keypad Enter, taken by the field (insertNewline:), so no default button fires and editing continues
linux-gtka GtkSearchEntry in the window’s AdwHeaderBarEnter (activate)
linux-qta QLineEdit on the window’s QToolBar, with a clear button and a QCompleter popupReturn (returnPressed); Return on a completion applies it first
windows-winuian AutoSuggestBox in the window toolbarQuerySubmitted: Return, the query glyph, or a picked suggestion
web-doman <input type=search enterkeyhint=search> in the docked toolbar strip, outside any formReturn, outside IME composition, after any <datalist> completion it accepted

The desktops and the web draw one bar per window, so the field rides it while its page is on top of its stack; Android keeps an open field through repaints of its bar and brings it back open when its page returns with a query in force.

Search::available offers the field only while it holds, for a page that learns whether it can be searched after it shows (a feed that loads first). A field withdrawn and offered again keeps its text. Scopes, reveal and placement belong to a surface’s search and do not apply to a page’s.

Submitting

Search::on_submit runs when the user presses Return or the keyboard’s Search action. It receives the submitted text, and the query binding already contains that text. Use this for an explicit server search; for a live filter, derive the results from the changing query instead.

Platform guidance