Debounced async search with request cancellation, combobox keyboard navigation (arrows, Enter,
Escape), and built-in loading, no-results and error states.
Basic
Try “berry”, or “xyz” to see the no-results state.
Last event: none yet
CwSearchInput exampleCopy code
<CwSearchInput
label="Search fruits"
placeholder="Type at least 3 chars…"
fetchSuggestions={fetchSuggestions}
bind:value={value}
/>
Sizes
States
The request always fails in this example.
Pick a fruit to continue
API
Usage and API reference
CwSearchInput is for async suggestion search. It handles debouncing, cancellation, keyboard navigation, and selected-value binding so you can focus on fetching and mapping results.
How to think about it
Return suggestions from `fetchSuggestions`The callback receives both the query string and an `AbortSignal`. Respect the signal so old requests can be cancelled cleanly.
Map objects into labels and valuesFor simple string arrays the defaults are enough. For object results, provide `mapSuggestionToLabel` and `mapSuggestionToValue`.
Separate typing from selectionUse `oninput` to respond to free typing and `onselect` when the user actually chooses a suggestion.
Props and callbacks
Native field props such as `name`, `required`, `autocomplete`, and `class` are also supported.
API
Type
Details
value
Default: ''
string
Current text value. Bind this when the parent owns the field state.