Skip to main content
OpenTUI provides a powerful styling system with RGBA colors, text attributes, and flexible color formats. This guide covers everything you need to create beautiful terminal UIs.

RGBA Color System

OpenTUI uses the RGBA class for consistent color representation. Colors are stored internally as normalized float values (0.0-1.0) for efficient processing.

Creating Colors

Using Colors

Colors can be applied to backgrounds, text, and borders:

Text Attributes

Text attributes control styling like bold, underline, and italic. They use bitwise OR to combine multiple attributes.

Available Attributes

Combining Attributes

Use bitwise OR (|) to combine multiple attributes:

Styled Text with Template Literals

The t template literal and helper functions make it easy to create rich, styled text.

Basic Styling

Color Helpers

Dynamic Content

Template literals support dynamic values and expressions:

Box Styling

Boxes support backgrounds, borders, and various border styles.

Border Styles

Complete Box Styling

Transparency and Alpha Blending

OpenTUI supports alpha transparency for creating layered UIs.

Creating Transparent Elements

FrameBuffer with Alpha

For custom rendering with transparency:

Theme Integration

React to terminal theme changes:

Color Palettes

Create consistent color schemes:

Performance Tips

Create RGBA objects once and reuse them instead of creating new ones frequently:
Update styled text only when values change:
String colors are parsed once and cached:

Examples

Status Dashboard

Styled Panel

Next Steps

Keyboard and Mouse

Handle user input events

Animations

Animate colors and properties