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
| Prop | Type | Default | Description |
|---|---|---|---|
modelValue (Vue) / value (React) | string | '' | Current value |
placeholder | string | 'Search…' | Placeholder hint |
size | 'sm' | 'md' | 'lg' | 'md' | Height |
disabled | boolean | false | Disabled |
clearable | boolean | true | Show clear button (when value is non-empty) |
shortcut | string | — | Right-side kbd hint text |
Events:
- Vue:
@update:modelValue,@search,@clear - React:
onChange,onSearch,onClear
反馈与讨论
Search input · Discussion