ui · Primitive
SearchInput
@devalok/shilp-sutra/ui/search-inputView in Storybook Preview
Variants
size
clearable
loading
Loading...
Reference
- Import: @devalok/shilp-sutra/ui/search-input
- Server-safe: No
- Category: ui
Props
size: "xs" | "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 is NOT wired to clear (the input is not
type="search"). Reset via the X button, or handle Escape yourself and call yourvaluesetter.
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