beamtea_style (beamtea v0.1.2)
View SourceA composable styling layer, inspired by charmbracelet/lipgloss.
A style is an immutable set of visual properties (colours, weight, padding, border, alignment, size). You build one up with chained setters — each returns a new style — and render/2 applies it to text:
S = beamtea_style:border(
beamtea_style:padding(
beamtea_style:foreground(beamtea_style:new(), pink), {1, 2}),
rounded),
beamtea_style:render(S, <<"Hello">>).Styles compose: merge/2 layers one over another, and join_horizontal/2 / join_vertical/2 arrange rendered blocks side-by-side or stacked — the building blocks for panels, button rows and modals. Colours may be a named beamtea_color atom, an xterm-256 integer, or a truecolor {R,G,B} triple.
Summary
Functions
Fix the content height (rows), padded/truncated per valign/2.
Place rendered blocks side by side, aligning their differing heights (top | middle | bottom).
Stack rendered blocks, aligning their differing widths (left | center | right).
Outer spacing (same shorthand as padding/2).
Layer Over on top of Base (Over's properties win).
An empty style.
A style from a property map (same keys the setters use).
Inner spacing. N for all sides, {V, H} for vertical/horizontal, or {Top, Right, Bottom, Left}.
Apply the style to Text, returning styled iodata() (possibly multiple lines). Order: inline SGR -> width/align -> height/valign -> padding -> border -> margin.
Fix the content width (columns); shorter lines are padded per align/2, longer ones truncated.
Types
-type box() :: non_neg_integer() | {non_neg_integer(), non_neg_integer()} | {non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer()}.
-type color() :: beamtea_color:name() | 0..255 | {0..255, 0..255, 0..255}.
-type style() :: map().
Functions
-spec height(style(), non_neg_integer()) -> style().
Fix the content height (rows), padded/truncated per valign/2.
Place rendered blocks side by side, aligning their differing heights (top | middle | bottom).
Stack rendered blocks, aligning their differing widths (left | center | right).
Outer spacing (same shorthand as padding/2).
Layer Over on top of Base (Over's properties win).
-spec new() -> style().
An empty style.
A style from a property map (same keys the setters use).
Inner spacing. N for all sides, {V, H} for vertical/horizontal, or {Top, Right, Bottom, Left}.
Apply the style to Text, returning styled iodata() (possibly multiple lines). Order: inline SGR -> width/align -> height/valign -> padding -> border -> margin.
-spec width(style(), non_neg_integer()) -> style().
Fix the content width (columns); shorter lines are padded per align/2, longer ones truncated.