/
1.1k
Sponsor

Search Input

Fuzzy search input with autocomplete

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

PropTypeDefault
optionsT[]-
getValue(item: T) => string-
valuestring-
defaultValuestring""
onValueChange(query: string) => void-
onChange(query: string) => void-
onSelect(item: T) => void-
placeholderstring"Search..."
labelstring-
maxResultsnumber5
idstring-
borderStyle"single" | "double" | "round" | "bold" | "singleDouble" | "doubleSingle" | "classic""round"
paddingXnumber1
cursorstring"█"
cursorOrigin{x: number; y: number}-
searchIconstring"🔍 "
resultCursorstring"› "

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 / Right move by grapheme, Home / End move to the boundaries, and Backspace / Delete remove one complete grapheme. Enter submits or confirms (Ctrl+Enter in TextArea); Tab / Shift+Tab leave 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.