Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/tui/src/components/textbox.ts>TextBox

🦕 Deno module for creating Terminal User Interfaces
Go to Latest
class TextBox
extends Box
import { TextBox } from "https://deno.land/x/tui@2.0.0/src/components/textbox.ts";

Component for creating interactive mutliline text input

If you need singleline input use Input component.

Examples

Example 1

new TextBox({
 parent: tui,
 lineNumbering: true,
 lineHighlighting: true,
 theme: {
   base: crayon.bgGreen,
   focused: crayon.bgLightGreen,
   active: crayon.bgYellow,
 },
 rectangle: {
   column: 1,
   row: 1,
   width: 10,
   height: 5,
 },
 zIndex: 0,
});

It supports validating input, e.g. number input would look like this:

Example 2

new TextBox({
 ...,
 validator: /\d+/,
});

If you need to use emojis or other multi codepoint characters set multiCodePointSupport property to true.

Example 3

new TextBox({
 ...,
 placeholder: "🧡",
 multiCodePointCharacter: true,
});

Constructors

new
TextBox(options: TextBoxOptions)

Properties

cursorPosition: Signal<CursorPosition>
drawnObjects: { box: BoxObject; lines: TextObject[]; lineNumbers: TextObject[]; cursor: TextObject; }
lineHighlighting: Signal<boolean>
lineNumbering: Signal<boolean>
multiCodePointSupport: Signal<boolean>
text: Signal<string>

Methods

draw(): void
interact(method: "keyboard" | "mouse"): void