Utility
Terminal
Installation
$ pnpm dlx shadcn@latest add @termcn/ink/text-input
Usage
import { TextInput } from "@/components/ui/text-input";<TextInput
label="Project Name"
placeholder="my-project"
onSubmit={(value) => console.log("Name:", value)}
/>Examples
Placeholder
A text input with placeholder text.
Terminal
With Label
Multiple labeled inputs stacked together.
Terminal
Cursor and editing
With showCursor (default true), use the left and right arrow keys to move the insertion point; type and Backspace apply at the cursor.
Terminal
API Reference
TextInput
| Prop | Type | Default |
|---|---|---|
value | string | - |
onChange | (value: string) => void | - |
onSubmit | (value: string) => void | - |
placeholder | string | "" |
mask | string | - |
showCursor | boolean | true |
highlightPastedText | boolean | false |
validate | (value: string) => string|null | - |
width | number | 40 |
label | string | - |
autoFocus | boolean | false |
id | string | - |
bordered | boolean | true |
borderStyle | "single" | "double" | "round" | "bold" | "singleDouble" | "doubleSingle" | "classic" | "round" |
paddingX | number | 1 |
cursor | 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.