Skip to main content

Overview

The TextRenderable component displays text content in your terminal UI. It supports styled text with colors and attributes, text wrapping modes, text selection, and dynamic composition using TextNodes.

Basic Usage

Props

string | StyledText
Text content to display. Can be a plain string or a StyledText object with inline styling.
string | RGBA
Foreground color for the text (e.g., "#FF0000" or "red").
string | RGBA
Background color for the text.
'none' | 'char' | 'word'
default:"'none'"
Text wrapping behavior:
  • 'none': No wrapping, text extends beyond bounds
  • 'char': Wrap at any character
  • 'word': Wrap at word boundaries
boolean
default:"false"
Enable text selection with mouse or keyboard.
string | RGBA
Background color for selected text.
string | RGBA
Foreground color for selected text.
boolean
default:"false"
Enable middle truncation with ellipsis when text exceeds available width.
number | string
Width of the text container. Accepts numbers (pixels) or strings like "100%" or "50%".
number | string
Height of the text container.

Methods

add()

Add a TextNode or string to the text content.

remove()

Remove a TextNode by ID.

clear()

Clear all content.

Examples

Styled Text

Word Wrapping

Selectable Text

Dynamic Composition with TextNodes

Using Helper Functions

Properties

content

Get or set the text content.

chunks

Access the underlying styled text chunks.

textNode

Access the root TextNode for advanced composition.
  • TextNode - Rich text composition with nested styling
  • Code - Syntax-highlighted code display
  • Markdown - Markdown rendering