Skip to main content
Module

x/tui/src/components/mod.ts>Label

🦕 Deno module for creating Terminal User Interfaces
Go to Latest
class Label
extends Component
Re-export
import { Label } from "https://deno.land/x/tui@2.1.4/src/components/mod.ts";

Component for creating multi-line, non interactive text

Examples

Example 1

new Label({
 parent: tui,
 text: "Hello\nthere"
 align: {
   horizontal: "center",
   vertical: "center",
 },
 theme: {
   base: crayon.magenta,
 },
 rectangle: {
   column: 1,
   row: 1,
 },
 zIndex: 0,
});

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

Example 2

new Label({
 ...,
 text: "🧡",
 multiCodePointCharacter: true,
});

Rectangle properties – width and height are calculated automatically by default. To overwrite that behaviour set overwriteRectangle property to true.

Example 3

new Label({
 ...,
 text: "1 2 3 cut me",
 overwriteRectangle: true,
 rectangle: {
   column: 1,
   row: 1,
   width: 6,
   height: 1,
 },
})

Constructors

new
Label(options: LabelOptions)

Properties

drawnObjects: { texts: TextObject[]; }
multiCodePointSupport: Signal<boolean>
overwriteRectangle: Signal<boolean>
text: Signal<string>

Methods

draw(): void