Search Input
Search input component
Overview
A compound search input with a search icon, clear button, and optional selectable options. Type to filter options, navigate with arrow keys, and select with Enter. Fully keyboard-accessible with combobox ARIA roles.
Usage
import { SearchInput } from "@leanicon/web-builder-library";Default
Empty search input with placeholder text and search icon.
Custom placeholder
With default value
Set defaultValue to pre-fill the input. The clear button appears automatically.
With options
Add SearchInput.Option children to create a filterable dropdown. Options are filtered as the user types, navigable with arrow keys, and selectable with Enter.
With option links
Options can include href to navigate on selection.
Many options (scrollable)
The dropdown scrolls when there are many options (max-h-64).
Dark mode
With default value — dark mode
With options — dark mode
Sub-components
Sub-component | Props | Description |
|---|---|---|
|
| A selectable option in the dropdown |
Props
SearchInput
Prop | Type | Default | Description |
|---|---|---|---|
|
|
| Initial input value |
|
|
| Input placeholder text |
|
| — |
|
|
| — | Force light or dark mode |
|
| — | Additional CSS classes on root |
SearchInput.Option
Prop | Type | Description |
|---|---|---|
|
| Filterable value — also set as input on selection |
|
| Optional link URL — wraps content in an anchor |
|
| Optional callback when option is selected |
|
| Option display content |
Keyboard interaction
Key | Action |
|---|---|
| Move highlight to next option |
| Move highlight to previous option |
| Select highlighted option |
| Close dropdown |
Notes
- Options are filtered by matching the
valueprop (or stringchildren) against the current query (case-insensitive). - The input uses
role="combobox"witharia-expanded,aria-autocomplete="list", andaria-activedescendantfor screen reader support. - The dropdown uses
role="listbox"withrole="option"on each item. - Dark mode: pass
colorScheme="dark"or place inside a.darkancestor.
Props
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
defaultValue | string | — | No | |
placeholder | string | Search... | No | |
colorScheme | enum | — | No | |
className | string | — | No | |
value | string | — | No | |
href | string | — | No | |
onSelect | (() => void) | — | No |