class Input
extends Box
import { Input } from "https://deno.land/x/tui@2.1.4/src/components/mod.ts";
Component for creating interactive text input
This component is 1 character high only!
If you need multiline input use TextBox
component.
Examples
Example 1
Example 1
new Input({
parent: tui,
placeholder: "type here",
theme: {
base: crayon.bgGreen,
focused: crayon.bgLightGreen,
active: crayon.bgYellow,
},
rectangle: {
column: 1,
row: 1,
width: 10,
},
zIndex: 0,
});
It supports validating input, e.g. number input would look like this:
Example 2
Example 2
new Input({
...,
validator: /\d+/,
});
You can also define whether text should be censored with *
character by specifying password
property.
Constructors
new
Input(options: InputOptions)Properties
cursorPosition: Signal<number>
drawnObjects: { box: BoxObject; text: TextObject; cursor: TextObject; }
multiCodePointSupport: Signal<boolean>
password: Signal<boolean>
placeholder: Signal<string | undefined>
text: Signal<string>
theme: InputTheme
validator: Signal<RegExp | undefined>