Utility
Terminal
Installation
$ pnpm dlx shadcn@latest add @termcn/ink/search-input
Usage
import { SearchInput } from "@/components/ui/search-input";<SearchInput
autoFocus
label="Search Packages"
options={["react", "vue", "svelte", "angular", "solid"]}
placeholder="Search..."
onSelect={(item) => console.log("Selected:", item)}
/>API Reference
SearchInput
| Prop | Type | Default |
|---|---|---|
options | T[] | - |
getValue | (item: T) => string | - |
value | string | - |
defaultValue | string | "" |
onValueChange | (query: string) => void | - |
onChange | (query: string) => void | - |
onSelect | (item: T) => void | - |
placeholder | string | "Search..." |
label | string | - |
maxResults | number | 5 |
id | string | - |
borderStyle | "single" | "double" | "round" | "bold" | "singleDouble" | "doubleSingle" | "classic" | "round" |
paddingX | number | 1 |
cursor | string | "█" |
cursorOrigin | {x: number; y: number} | - |
searchIcon | string | "🔍 " |
resultCursor | string | "› " |
Notes
Accessibility
termcn exposes the following behavior through Ink's terminal accessibility APIs. This is not a browser ARIA or general WCAG-conformance claim.
- Keyboard:
Left/Rightmove by grapheme,Home/Endmove to the boundaries, andBackspace/Deleteremove one complete grapheme.Entersubmits or confirms (Ctrl+Enterin TextArea);Tab/Shift+Tableave through Ink focus traversal. - Focus and composition: Input is active only while the component's focus target is focused, enabled, active, and inside the topmost focus scope.
- Screen reader: Ink labels and semantic state expose the component without relying on visual styling alone.