SearchInput
HkSearchInput is the bare search field: a magnifier glyph on the left, a native type="search" element and a clear button that appears while the field holds text. It is a box and a field with no caption, no hint and no error line — the shape a list header or a command bar wants, not the shape a form row wants.
- For a labelled field inside a form, use HkInput with a #prefixIcon magnifier.
- For a search entry point in page chrome that opens a palette, prefer the palette trigger over an always-open field.
- For filtering a data table, keep this field but bind it with a short debounce.
Import
;
use *; // SearchInput, SearchInputSize
use *; // rsx!, VNode
The Rust form is a plain function, SearchInput(SearchInputProps { … }). Unlike Vue, its debounce prop is accepted and inert: the mirror fires search on Enter only and leaves the debounce window to the host.
Sizes
Three steps — sm, md (the default), lg — carried by hk-search-input-{size}. sm suits a dense toolbar, lg a full-width hero search.
The clear button
The trailing button renders only while the field holds text and is enabled. Pressing it emits update:modelValue with an empty string, then clear; in Vue the field is refocused so the user can type the next query straight away. Pass clearAriaLabel to name the button yourself — it defaults to the localized "Clear search".
Debounce and disabled
Vue watches modelValue and emits search on every change — through a setTimeout of debounce milliseconds when that prop is above 0 — and flushes the pending timer on Enter. The Rust mirror reads no field value from a key event, so its Enter passes the controlled model_value and never schedules a timer. A disabled field drops the size marker's interactivity, the clear button and all input at once. The mirror's fence keeps to the field itself: debounce is accepted and inert there, and the Last-search counter is a Vue-side interaction a static snapshot cannot run.
API
Vue
Props
| Name | Type | Default | Required |
|---|---|---|---|
| modelValue | String | "" | — |
| placeholder | String | undefined | — |
| disabled | Boolean | false | — |
| size | <code>String as PropType<"sm" | "md" | "lg"></code> | "md" | — |
| debounce | Number | 0 | — |
| clearAriaLabel | String | "" | — |
| role | String | undefined | — |
Emits
| Event | Payload |
|---|---|
| update:modelValue | string |
| search | string |
| clear | — |
Rust
Props — SearchInput
| Prop | Type | Default | Description |
|---|---|---|---|
| model_value | String | "" | Vue: modelValue, default "" (controlled). |
| placeholder | Option<String> | None | Native placeholder; None falls back to the i18n default exactly like Vue's placeholder ?? t("hikari::searchInput.placeholder", "Search…"). |
| disabled | bool | false | — |
| size | SearchInputSize | SearchInputSize::Md | Size step (hk-search-input-{size}). |
| debounce | f64 | 0.0 | Vue's debounce (ms). |
| clear_aria_label | String | "" | Vue's clearAriaLabel; the empty default falls back to the i18n string, exactly Vue's <code>clearAriaLabel || t(...)</code>. |
| oninput | Option<EventHandler<String>> | None | Vue: update:modelValue — the field's new text. |
| onsearch | Option<EventHandler<String>> | None | Vue: the search emit (the mirror fires it on Enter only). |
| onclear | Option<EventHandler<()>> | None | Vue: the clear emit (after the clearing update:modelValue). |
Accessibility
- The field is a native <input type="search">, so assistive technology announces it as a search box and mobile keyboards offer a search key. It has no caption, so give it a name: an aria-label on the element, or a visible label wired up with for / id.
- In Vue every undeclared attribute lands on the field, not the box — aria-label, aria-controls, aria-activedescendant and role="combobox" (declare role as a prop) reach the input. class and style stay on the box. The Rust mirror has no attribute bag: the field carries the attributes it renders.
- The clear button is named by clearAriaLabel (or the localized default) and is removed from the Tab order on purpose (tabindex="-1"): Escape or the keyboard's own clearing keeps the field focused, and a Tab past the field never stops on it.
- search fires on every change and is not a live region: debounce it at the source rather than announcing every intermediate value.
- Label this field, not just its box: the box is chrome, the field is the control.
Related components
- HkInput — the labelled field, with a magnifier as its #prefixIcon.
- HkNumberInput — the numeric field with a stepper column.
- HkPhoneInput — a field whose left affix is a country picker.
- HkOtpInput — one cell per character for one-time codes.