Utility
AI
Terminal
Installation
pnpm dlx shadcn@latest add https://termcn.dev/r/text-input.json
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
import { TextInput } from "@/registry/ui/text-input";
export default function TextInputPlaceholder() {
return <TextInput placeholder="Search packages..." />;
}
With Label
Multiple labeled inputs stacked together.
Terminal
import { Box } from "ink";
import { TextInput } from "@/registry/ui/text-input";
export default function TextInputLabel() {
return (
<Box flexDirection="column" gap={1}>
<TextInput label="Name" placeholder="Enter your name" />
<TextInput label="Email" placeholder="you@example.com" />
</Box>
);
}
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
import { Box, Text } from "ink";
import { TextInput } from "@/registry/ui/text-input";
export default function TextInputCursor() {
return (
<Box flexDirection="column" gap={1}>
<Text dimColor>← → move cursor · type / backspace at cursor</Text>
<TextInput
autoFocus
label="Editable"
placeholder="Try arrows"
showCursor
/>
</Box>
);
}
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 | "█" |