Creating a style
Every style starts fromStyle.newStyle(). Methods return this, so the entire style is configured in a single chain and applied by calling render(...).
render() accepts one or more strings. Multiple strings are joined with a space before styling is applied.
Colors
All colors implementTerminalColor and can be passed to .foreground() and .background().
ANSI-256 and hex colors
Color.color(String) accepts ANSI-256 index strings ("0"–"255") and hex color strings ("#FF5F87").
Adaptive colors
AdaptiveColor selects between a light and dark variant depending on whether the terminal has a dark background.
Text attributes
Width and height
Set explicit dimensions to constrain content. Text is wrapped to fit the specified width.maxWidth and maxHeight:
Padding
Padding uses CSS-like shorthand: one value applies to all sides, two values apply to vertical then horizontal, four values apply top → right → bottom → left.Margins
Margins work identically to padding but add space outside any border.Borders
Choose a border style fromBorders and apply it with .border().
Apply borders selectively with
boolean side flags:
Alignment
Layout: joining styled blocks
Join combines multiple rendered strings side-by-side or stacked. Pass a Position to control alignment along the cross-axis.
Status bar example
This pattern, taken from the Lipgloss examples, builds a multi-segment status bar usingJoin.joinHorizontal:
Copying and inheriting styles
Use.copy() to create an independent clone of a style (safe for modification without affecting the original):
.inherit(other) to fill in only the properties that have not been explicitly set on the receiver:
The Elm Architecture
Model, Update, and View pattern.
Messages and commands
Events and side effects in TUI4J.