termino

Input

Text input field with cursor, placeholder text, and focus states. Focus the input to receive keyboard input.

~/components/input — click & type
live
$ termino input-demo — focus me and type
name enter your name
username opentui_dev
events awaiting input…
chars 0 enter/submit disabled

##Renderable API

tsrenderable
1import { InputRenderable, InputRenderableEvents, createCliRenderer } from "@opentui/core"
2
3const renderer = await createCliRenderer()
4
5const input = new InputRenderable(renderer, {
6id: "name-input",
7width: 25,
8placeholder: "Enter your name...",
9})
10
11input.on(InputRenderableEvents.CHANGE, (value) => {
12console.log("Input value:", value)
13})
14
15input.focus()
16renderer.root.add(input)

##Construct API

tsconstruct
1import { Input, createCliRenderer } from "@opentui/core"
2
3const renderer = await createCliRenderer()
4
5const input = Input({
6placeholder: "Enter your name...",
7width: 25,
8})
9
10input.focus()
11renderer.root.add(input)

##Focus states

The CHANGE event is emitted after text insertion and deletion operations, and when assigning a different value. The listener receives the current value.

##Password fields

Style an input as a password field with a masked value:

ts
1const passwordInput = Input({
2id: "password-input",
3width: 20,
4placeholder: "••••••••",
5backgroundColor: "#222",
6focusedBackgroundColor: "#333",
7textColor: "#FFF",
8cursorColor: "#0F0",
9})
10
11const mask = (value: string) => "•".repeat(value.length)
12
13// Hook into change events to render the masked value
14passwordInput.on("change", (value) => {
15console.log("typed:", value)
16})

##Tab navigation

Add tab navigation between multiple inputs:

ts
1const inputs = [usernameInput, passwordInput]
2let focusIndex = 0
3
4renderer.keyInput.on("keypress", (key) => {
5if (key.name === "tab") {
6 focusIndex = (focusIndex + 1) % inputs.length
7 inputs[focusIndex].focus()
8}
9})

##Key bindings

~/keymap
TabMove focus to next input
Shift+TabMove focus to previous input
BackspaceDelete previous character
EnterSubmit (respects minLength)
Home / EndJump to start / end
Ctrl+UClear input

##Properties

properties
proptypedefaultdescription
widthnumber | "auto" | "{n}%""auto"Input field width
valuestring""Initial text value
placeholderstring""Placeholder text when empty
minLengthnumber0Minimum UTF-16 length required for submit
maxLengthnumber1000Maximum UTF-16 length
backgroundColorstring | RGBAtransparentBackground when unfocused
focusedBackgroundColorstring | RGBAtransparentBackground when focused
textColorstring | RGBA"#FFFFFF"Text color
cursorColorstring | RGBA"#FFFFFF"Cursor color
position"relative" | "absolute""relative"Effective positioning mode