Components/SearchInput

SearchInput

An input with a built-in search icon that searches on Enter.

VerifiedSince 0.3.4

Usage

Basic

Enter emits search immediately.

Loading demo...

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 TxSearchInput for keyword-and-Enter flows; use TxSearchSelect when 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 searchDebounce to 0 only for local or fully cached searches.
  • Use TuffInput directly when you need a custom prefix or suffix.

API Reference

Props

PropTypeDefaultDescription
modelValuestring''Input value, bound with v-model.
placeholderstring'Search'Placeholder text.
disabledbooleanfalseBlocks typing, clearing, and remote search.
clearablebooleantrueShows the clear button when there is a value.
remotebooleanfalseEmits debounced search events while typing.
searchDebouncenumber200Remote-search debounce in milliseconds.

Events

EventParamsDescription
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

NameTypeDescription
focus()() => voidFocuses the input.
blur()() => voidBlurs the input.
clear()() => voidClears the value and emits clear.
setValue(v)(v: string) => voidSets the input value.
getValue()() => stringReturns the input value.

Technologies

  • Wraps TuffInput with a built-in search icon; clearing and the exposed methods forward to TuffInput.
  • Source: packages/tuffex/packages/components/src/search-input/.
查看源码
packages/tuffex/packages/components/src/search-input/index.ts