RGBA Color System
OpenTUI uses theRGBA 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
Thet 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
- Single
- Double
- Rounded
- Bold
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
Reuse RGBA Objects
Reuse RGBA Objects
Create RGBA objects once and reuse them instead of creating new ones frequently:
Minimize Dynamic Text Updates
Minimize Dynamic Text Updates
Update styled text only when values change:
Use String Colors for Simple Cases
Use String Colors for Simple Cases
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