/
1.1k
Sponsor

Text Input

Single-line text input with placeholder, validation, mask

Terminal

Installation

$ pnpm dlx shadcn@latest add @termcn/opentui/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

PropTypeDefault
valuestring-
onChange(value: string) => void-
onSubmit(value: string) => void-
placeholderstring""
maskstring-
showCursorbooleantrue
highlightPastedTextbooleanfalse
validate(value: string) => string|null-
widthnumber40
labelstring-
autoFocusbooleanfalse
idstring-
borderedbooleantrue
borderStyle"single" | "double" | "round" | "bold" | "singleDouble" | "doubleSingle" | "classic""round"
paddingXnumber1
cursorstring"█"