Components/SearchSelect

SearchSelect

A select that searches as you type and fills in the picked option.

VerifiedSince 0.3.4

Usage

Basic

Local mode filters options by label and shows them all when the input is empty.

Loading demo...

remote turns off local filtering and emits search after the debounce or on Enter; write the results back to options.

Loading demo...

Filter Toolbar

TxSearchSelect holds structured filters such as scope, type, or status; the keyword goes to TxSearchInput, and TxSearchEmpty shows when nothing matches.

Loading demo...

Best Practices

  • Keep options small in local mode; for large sources use remote and write results back from outside.
  • Keep each label stable and readable; local filtering matches only the label.
  • Pick only from a controlled option list; use TxSearchInput for free-form keyword search.
  • Treat disabled options as explanatory entries, never as the only result.

API Reference

Props

PropTypeDefaultDescription
modelValuestring | number''Selected value, bound with v-model.
placeholderstring'Search'Placeholder of the input.
disabledbooleanfalseDisables the input, panel, and focus-to-open; no remote search is emitted.
clearablebooleantrueShows the clear button, which clears the selected value.
optionsTxSearchSelectOption[][]Options to choose from; disabled options can't be picked.
loadingbooleanfalseShows a spinner in the input suffix.
remotebooleanfalseTurns off local filtering and emits search instead.
searchDebouncenumber200Debounce of the remote search, in milliseconds.
dropdownMaxHeightnumber280Maximum panel height (px); taller content scrolls inside.
dropdownOffsetnumber6Gap between the panel and the input.
panelVariant'solid' | 'dashed' | 'plain''solid'Panel border style, as TxCard variant.
panelBackground'pure' | 'mask' | 'blur' | 'glass' | 'refraction''refraction'Panel background, as TxCard background.
panelShadow'none' | 'soft' | 'medium''soft'Panel shadow, as TxCard shadow.
panelRadiusnumber18Panel corner radius, as TxCard radius.
panelPaddingnumber6Panel padding, as TxCard padding.

Events

EventParamsDescription
update:modelValue(v: string | number)Fires after an enabled option is picked or the value is cleared.
change(v: string | number)Fires together with update:modelValue.
search(q: string)In remote mode, fires after the debounce or on Enter.
select(opt: TxSearchSelectOption)Fires with the picked enabled option, before the panel closes.
open-Fires when the panel opens.
close-Fires when the panel closes; cancels any pending remote search.

Exposed Methods

NameTypeDescription
open()() => voidOpens the panel unless disabled.
close()() => voidCloses the panel.
focus()() => voidFocuses the internal TxInput.
blur()() => voidBlurs the internal TxInput.
clear()() => voidClears the input and the selected value.

Types

EXAMPLE.TS
export interface TxSearchSelectOption {
  value: string | number
  label: string
  disabled?: boolean
}

Overview

  • Remote mode shows options as given and caches nothing.
  • Clearing emits update:modelValue and change with ''.
  • The input text survives closing the panel; reopening does not reset it.

Technologies

  • The panel is hosted by TxPopover. No slots are exposed: the prefix, loading suffix, empty state, and option rows render internally to keep keyboard and popover behavior consistent.
  • Source: packages/tuffex/packages/components/src/search-select/.
查看源码
packages/tuffex/packages/components/src/search-select/index.ts