Search Input
Terminal-styled search input with / prefix and keyboard event callbacks. Supports controlled and uncontrolled modes.
Installation
dgadd is not public on npm yet. Until the first release, pack @diffgazer/add from the repository and install that tarball into this app, which is what puts dgadd on pnpm exec.
The hosted registry is not public yet because r.b4r7.dev does not resolve. Use this source checkout or a local registry preview until the endpoint returns 200.
Diffgazer packages are not yet published to npm. Until the first release, pack @diffgazer/ui and @diffgazer/keys from the repository and install those tarballs.
UI components require Tailwind CSS v4. Local copy mode imports src/styles/styles.css; package mode uses @diffgazer/ui CSS once packages are available.
Usage
Examples
Custom
Sizes, invalid, disabled
Keyboard Navigation
API Reference
SearchInput
Accessibility
Keyboard Navigation
SearchInput provides onEscape and onEnter callback props. For arrow-key navigation in an adjacent list, use the onKeyDown prop or @diffgazer/keys's useNavigation hook. The search-input-keyboard example shows how to wire arrow keys via onKeyDown.
| Key | Action |
|---|---|
| Escape | Clears the current value when it is non-empty; otherwise calls onEscape when provided. |
| Enter | Calls onEnter when provided. |
| ArrowRight | With the caret and selection at the end of a non-empty value, moves focus to the clear button; elsewhere it keeps its native caret move. |
| ArrowLeft (on the clear button) | Returns focus to the search input. |
| Arrow keys / other keys | Forward through onKeyDown so a parent listbox, combobox, or custom search flow can own navigation. |
With keyboard navigation
Notes
Controlled & Uncontrolled
Pass value + onChange for controlled mode. Pass defaultValue (or nothing) for uncontrolled mode. Works like every other @diffgazer/ui component via useControllableState.
Keyboard Callbacks
SearchInput provides onEscape and onEnter callback props for common search patterns (clear and submit). For arrow-key list navigation, use onKeyDown or @diffgazer/keys's useNavigation hook.
Custom Prefix
The prefix prop replaces the default / character with any ReactNode. Set prefix={null} to hide it entirely.
Size Variants
Pass size="sm", size="md" (default), or size="lg" to control the input and wrapper sizing.
Invalid & Disabled
Set aria-invalid to show destructive border styling. Pass disabled to prevent interaction.
Source
Install via CLI: pnpm exec dgadd add ui/search-input.
Highlighted source loads after this disclosure opens. Browse the source repository.