Utility
AI
Terminal
text-input-demo
No opentui live preview is registered for this example yet.
Installation
pnpm dlx shadcn@latest add @termcn/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
text-input-placeholder
No opentui live preview is registered for this example yet.
With Label
Multiple labeled inputs stacked together.
Terminal
text-input-label
No opentui live preview is registered for this example yet.
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
text-input-cursor
No opentui live preview is registered for this example yet.
API Reference
TextInput
| Prop | Type | Default |
|---|---|---|
value | string | undefined |
onChange | (value: string) => void | undefined |
onSubmit | (value: string) => void | undefined |
placeholder | string | "" |
mask | string | undefined |
showCursor | boolean | true |
highlightPastedText | boolean | false |
validate | (value: string) => string|null | undefined |
width | number | 40 |
label | string | undefined |
autoFocus | boolean | false |
id | string | undefined |
bordered | boolean | true |
borderStyle | "single" | "double" | "round" | "bold" | "singleDouble" | "doubleSingle" | "classic" | "round" |
paddingX | number | 1 |
cursor | string | "█" |