FlexBox layout + simple sort/filter table
FlexBox layout engine for terminal grids — ratio-based item sizing, gap, justify, align. Plus a simple table with sort, filter, cursor nav, and column styling. Viewport and Scrollbar compose the sugar-bits SSOT.
composer require sugarcraft/sugar-stickers
use SugarCraft\Stickers\Flex\{FlexBox, FlexItem};
use SugarCraft\Stickers\Table\{Table, Column};
$flex = FlexBox::row(
FlexItem::new('LEFT')->withRatio(1),
FlexItem::new('RIGHT')->withRatio(2),
)->withGap(2);
$table = (new Table())
->addColumn(Column::make('Name', 20))
->addRow(['Alice'])
->addRow(['Bob'])
->sortBy(0, true);
| Class | Method | Description |
|---|---|---|
| FlexBox | row(...items) | Create horizontal flexbox |
| FlexBox | column(...items) | Create vertical flexbox |
| FlexBox | withGap(pixels) | Set gap between items |
| FlexItem | new(content) | Create flex item |
| FlexItem | withRatio(n) | Set size ratio |
| Table | new() | Create table |
| Table | addColumn(col) | Add table column |
| Table | addRow(cells) | Add table row |
| Table | sortBy(col, asc) | Sort by column |
| Viewport | new(w, h) | Create viewport (80×24 default) |
| Viewport | withContent(str, w, h) | Create with string content |
| Viewport | withScrollbar(bool) | Toggle scrollbar display |
| Viewport | lineUp/Down(n) | Scroll by n lines |
| Viewport | gotoTop/Bottom() | Jump to start/end |
| Scrollbar | vertical() | Vertical scrollbar |
| Scrollbar | horizontal() | Horizontal scrollbar |
| Scrollbar | view(state, height) | Render scrollbar |
VHS-recorded GIFs of every example shipped with the library. Regenerated automatically on every push that touches the source.