5Sponsor

Text Input

Single-line text input with placeholder, validation, mask

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

PropTypeDefault
valuestringundefined
onChange(value: string) => voidundefined
onSubmit(value: string) => voidundefined
placeholderstring""
maskstringundefined
showCursorbooleantrue
highlightPastedTextbooleanfalse
validate(value: string) => string|nullundefined
widthnumber40
labelstringundefined
autoFocusbooleanfalse
idstringundefined
borderedbooleantrue
borderStyle"single" | "double" | "round" | "bold" | "singleDouble" | "doubleSingle" | "classic""round"
paddingXnumber1
cursorstring"█"