Preview Updated 2026-05-10

Search input

Input preset with a search icon, clear button, and optional shortcut hint. Pressing Enter fires the search event.

Basic usage

A fixed search icon on the left; when the value is non-empty an × clear button appears on the right and clicking it clears and fires clear. Enter fires search(value).

<CfSearchInput
v-model="q"
placeholder="Search docs…"
@search="(v) => console.log(v)"
/>
<CfSearchInput
value={q}
onChange={setQ}
placeholder="Search docs…"
onSearch={(v) => console.log(v)}
/>

Shortcut hint

shortcut mounts a kbd hint at the far right. Often paired with a page-level listener on Ctrl K / ⌘K to focus the search box.

<CfSearchInput v-model="q" placeholder="Press Ctrl K to focus" shortcut="Ctrl K" />
<CfSearchInput value={q} onChange={setQ} placeholder="Press Ctrl K to focus" shortcut="Ctrl K" />

Three sizes

size matches Input / Select — sm / md (default) / lg.

<CfSearchInput v-model="a" size="sm" />
<CfSearchInput v-model="b" size="md" />
<CfSearchInput v-model="c" size="lg" />
<CfSearchInput value={a} onChange={setA} size="sm" />
<CfSearchInput value={b} onChange={setB} size="md" />
<CfSearchInput value={c} onChange={setC} size="lg" />

Disabled

disabled greys the control and ignores clicks.

<CfSearchInput model-value="(disabled)" disabled />
<CfSearchInput value="(disabled)" disabled />

API

PropTypeDefaultDescription
modelValue (Vue) / value (React)string''Current value
placeholderstring'Search…'Placeholder hint
size'sm' | 'md' | 'lg''md'Height
disabledbooleanfalseDisabled
clearablebooleantrueShow clear button (when value is non-empty)
shortcutstringRight-side kbd hint text

Events:

  • Vue: @update:modelValue, @search, @clear
  • React: onChange, onSearch, onClear

反馈与讨论

Search input · Discussion

0
0 / 600
一键发送
正在加载评论...