SearchInput
An input with a built-in search icon that searches on Enter.
Usage
Basic
Enter emits search immediately.
Loading demo...
Remote Search
remote emits search once typing pauses for searchDebounce ms; the host renders the results panel.
Loading demo...
Filter Toolbar
TxSearchInput takes the keyword, TxSearchSelect the scope, and TxSearchEmpty shows when nothing matches.
Loading demo...
Best Practices
- Use
TxSearchInputfor keyword-and-Enter flows; useTxSearchSelectwhen results need a panel or the picked value fills the field. - With
remote, Enter and the debounce can emit the same query, so keep request handling idempotent. - Don't rely on the placeholder alone for meaning; give dense toolbars an external label or context.
- Set
searchDebounceto0only for local or fully cached searches. - Use
TuffInputdirectly when you need a custom prefix or suffix.
API Reference
Props
| Prop | Type | Default | Description |
|---|---|---|---|
modelValue | string | '' | Input value, bound with v-model. |
placeholder | string | 'Search' | Placeholder text. |
disabled | boolean | false | Blocks typing, clearing, and remote search. |
clearable | boolean | true | Shows the clear button when there is a value. |
remote | boolean | false | Emits debounced search events while typing. |
searchDebounce | number | 200 | Remote-search debounce in milliseconds. |
Events
| Event | Params | Description |
|---|---|---|
update:modelValue | (v: string) | Fires when the input value changes. |
input | (v: string) | Fires together with update:modelValue. |
focus | (e: FocusEvent) | Fires when the input gains focus. |
blur | (e: FocusEvent) | Fires when the input loses focus. |
clear | - | Fires after the clear button resets the value. |
search | (v: string) | Fires on Enter, and with remote also after the debounce. |
Exposed Methods
| Name | Type | Description |
|---|---|---|
focus() | () => void | Focuses the input. |
blur() | () => void | Blurs the input. |
clear() | () => void | Clears the value and emits clear. |
setValue(v) | (v: string) => void | Sets the input value. |
getValue() | () => string | Returns the input value. |
Technologies
- Wraps
TuffInputwith a built-in search icon; clearing and the exposed methods forward toTuffInput. - Source:
packages/tuffex/packages/components/src/search-input/.
查看源码
packages/tuffex/packages/components/src/search-input/index.ts