Skip to content
Harness Design System Harness Design System Harness Design System

Search Input

Below is an example of how to implement a search input that displays the current search value using React state. The SearchInput component includes a built-in 300ms debounce to prevent excessive callbacks when typing:

Search with Navigation

Below is an example of how to implement a search input with navigation controls. The navigation buttons (previous, next, and clear) appear when you start typing.

Navigation:

  • Click the button or press Shift+Enter to go to the previous result
  • Click the button or press Enter to go to the next result
  • Click the × button to clear the search
  • Click the ⌘F badge or press ⌘F (Mac) / Ctrl+F (Windows/Linux) to focus the search input

Usage

import { SearchInput } from '@harnessio/ui/components'
//...
return (
<SearchInput
placeholder="Type to search..."
onChange={(value) => setSearchValue(value)}
/>
)

API Reference

Prop
Required
Default
Type
debouncefalse300number | boolean
wrapperClassNamefalsestring
labelfalsestring
captionfalsestring
errorfalsestring
warningfalsestring
optionalfalsefalseboolean
idfalsestring
disabledfalsefalseboolean
classNamefalsestring
inputContainerClassNamefalsestring
themefalse'default''default' | 'success' | 'danger' | 'warning'
sizefalse'md''md' | 'sm'
suffixfalseReactNode
valuefalsestring
defaultValuefalsestring
onChangefalse (value: string) => void
placeholderfalseSearchstring
readOnlyfalsefalseboolean
showPrevNextButtonsfalsefalseboolean
counterfalsestring
onEnterfalse(text: string, reverse?: boolean) => void
onPrevfalse(text: string) => void
onNextfalse(text: string) => void
onKeyDownfalse(event: React.KeyboardEvent<HTMLInputElement>) => void