Search field
A search field is a place to enter and refine the words used to find content. It suits filtering a visible collection or sending a query to a service.
day-pieces uses the platform’s search control and keeps its query in sync with app state. The app
uses that query to filter or fetch results.
Add to your app
This control is included in day-pieces
and re-exported through day::prelude::*. No additional crate or control feature is required.
The selected toolkit supplies its native implementation; day::searchfield::support() reports
its availability after the Day runtime starts.
| Platforms / toolkits | Availability |
|---|---|
| AppKit, UIKit, GTK, Qt, Android, WinUI, ArkUI | Toolkit-specific search input. |
| Web | Browser search input. |
The UI snippets use generated res::str accessors from an app’s Fluent catalog; see the
example messages and catalog setup.
Authoring
use day::searchfield::search_field;
let query = Signal::new(String::new());
search_field(query)
.placeholder(res::str::search_fruit())
.id(id!(search))
search_field(query) takes a Signal<String> bound two-way: every native edit writes the text back
to the signal, and setting the signal (e.g. a Clear button doing query.set(String::new())) patches the
control. .placeholder(impl IntoText) sets the empty-state prompt; it accepts a constant,
Signal<String>, or closure, read once for the initial value (the placeholder is fixed at build).
SearchField implements Piece, so .id()/.a11y()/.frame() chain via Decorate. Like day-core’s
text_field it is a width-growing leaf (grow_w = true, natural single-line height): a search
field fills its row, so constrain it with .frame(w, h) if you need a fixed width.
Toolkit implementations
Platform guidance: Apple: search fields; Android: search interface.
| AppKit | UIKit | GTK | Qt | Android | WinUI | ArkUI |
|---|---|---|---|---|---|---|
NSSearchField | UISearchTextField (iOS 13+) | GtkSearchEntry | QLineEdit search shim (clear button + leading magnifier) | EditText (single-line, IME_ACTION_SEARCH) | AutoSuggestBox (query magnifier) | ArkTS Search (the toolkit’s controls/searchfield/platform/harmony/ets; the C node API has no search kind) |
Limits
The placeholder is read when the control is built. The builder does not provide an enabled binding, a submit callback, or scoped-search tokens. Use a text field for an explicit submit action, or page search to integrate search with navigation and toolbar placement.