-
Notifications
You must be signed in to change notification settings - Fork 9
Component SearchInput
MeowLynxSea edited this page Jun 13, 2026
·
5 revisions
A single-line text input with a leading search icon and a trailing clear (×) button when non-empty. Escape clears the value.
use yororen_ui::headless::search_input::search_input;use yororen_ui::headless::search_input::search_input;
search_input("search-box")
.placeholder("Search…")
.value(self.query.clone())
.on_change({
let entity = cx.entity();
move |new: &str, _window, cx| {
entity.update(cx, |s, _cx| s.query = new.to_string());
}
})
.on_clear(|_window, _cx| {
// Called after the renderer has already cleared the input.
})
.render(cx, window)| Method | Purpose |
|---|---|
placeholder(text) |
Hint shown when empty. |
value(s) |
Current value (a String-like type, owned). |
disabled(v) |
Disable interaction. |
on_change(closure) |
Fn(&str, &mut Window, &mut App) + 'static + Send + Sync. Fired on each accepted change. |
on_submit(closure) |
Fn(&str, &mut Window, &mut App) + 'static + Send + Sync. Fired on Enter. |
on_clear(closure) |
Fn(&mut Window, &mut App) + 'static + Send + Sync. Fired when the user dismisses the value (Escape, × click). |
- Factory takes
(id)only — the focus handle and the keyed state are minted by the renderer. -
.render(cx, window)is two-arg and returnsAnyElement. Thewindowis required because the renderer hooks theEntityInputHandlerfor IME / paste. -
on_changereceives&str(the new UTF-8 text), notSharedString. Convert with.to_string()before storing in your view. -
on_clearis a two-argument callback (&mut Window, &mut App) — there is no value argument because the renderer has already cleared the input by the time it fires.
TextInput, PasswordInput, KeybindingInput
Yororen UI v0.3.0 · repository · Apache-2.0 · This wiki documents Yororen UI v0.3.0.
This wiki documents Yororen UI v0.3.0 — the headless-core, swappable-renderer build.