ui · Primitive
SearchInput
@devalok/shilp-sutra/ui/search-inputView in Storybook Hand-curated previews ship in rolling waves. See it live in Storybook →
Reference
Props
size: "sm" | "md" | "lg"
loading: boolean (shows spinner instead of clear button)
onClear: () => void (shows X button when value is non-empty)
value: string
onChange: ChangeEventHandler
(plus standard input attributes except native "size")
Defaults
size: "md"
Example
<SearchInput
value={query}
onChange={(e) => setQuery(e.target.value)}
onClear={() => setQuery('')}
placeholder="Search tasks..."
loading={isSearching}
/>
Composability
- Purpose-built variant of Input for search — renders the leading search icon and a contextual clear/loading trailing slot. For anything more custom, use Input with explicit
startSection/endSection. onClearmakes the X button appear only whenvalueis non-empty. Pair them so users can reset.loading={true}swaps the clear button for a spinner witharia-busy="true"on the input — useful for debounced/async search.- Doesn't auto-consume FormField (no
stateprop) — wrap a regular Input inside FormField for validated search fields. - Keyboard: Escape auto-triggers
onClearwhen wired (handled viatype="search"'s native behavior on most browsers).
Gotchas
- HTML native "size" attribute is excluded — use CSS width instead
- Clear button only appears when both
onClearis provided ANDvalueis non-empty
Changes
v0.15.0
- Changed
lgsize font changed fromtext-ds-lg(18px) totext-ds-md(14px) — all input sizes now use 14px for consistency
v0.2.0
- Changed
inputSizeprop renamed tosizeto match Input API
v0.1.1
- Fixed Token compliance — replaced
pl-10 pr-9and icon offsets with explicit arbitrary values
v0.1.0
- Added Initial release