← All libraries

CandySprinkles

✨ CandySprinkles

Declarative styling + layout

port of lipgloss styling layout borders tables trees

Style, Border, Table, List, Tree, Layout::join, Place, multi-layer Canvas. Pure rendering — no I/O — so you can render frames inside a unit test.

Install

composer require candycore/candy-sprinkles

Quickstart

use CandyCore\Sprinkles\{Style, Border, Layout, Position};
use CandyCore\Sprinkles\Table\Table;
use CandyCore\Core\Util\Color;

$banner = Style::new()
    ->bold()
    ->foreground(Color::hex('#ff5f87'))
    ->padding(0, 2)
    ->render('hello, candy world');

$table = Table::new()
    ->headers('Name', 'Age')
    ->row('Alice', '30')
    ->row('Bob', '25')
    ->border(Border::rounded())
    ->render();

echo Layout::joinVertical(Position::LEFT, $banner, $table);

What's in the box

StyleForeground / background, bold / italic / underline, padding, margin, width, alignment. Immutable with*() chain.
BorderSix built-in styles + custom. Border::rounded(), thick(), double(), hidden(), normal(), ascii().
TableHeaders, rows, per-cell styleFunc. ANSI-aware width calc with grapheme cluster support.
List + TreeBulleted lists and ASCII trees with custom enumerators.
LayoutjoinHorizontal, joinVertical, place, placeOverlay for popovers.
CanvasMulti-layer compositor. Z-ordered overlays, alpha-aware merge, ideal for modals + tooltips.

Source & demos

Try the quickstart →

Demos.

VHS-recorded GIFs of every example shipped with the library. Regenerated automatically on every push that touches the source.

Style

Style

Foreground / background, bold, italic — chained Style builders.
Border

Border

All six built-in border styles.
Table

Table

Per-cell styleFunc with header highlighting.
List

List

Bulleted list with custom enumerator.
Tree

Tree

Indented tree with branch glyphs.
Dashboard

Dashboard

Multi-panel layout joined horizontally + vertically.
Canvas

Canvas

Multi-layer compositor with z-ordered overlays.